4

我想删除那里的空格。我是一个外行用户。如果我犯了一个愚蠢的错误,请原谅我。提前致谢。查看有空间的图像并参考代码。页面设计图片

html代码:

    <html>
    <head>
    <title>CSS</title>
    <link href="styles.css" rel="stylesheet">
    </head>

    <body>
    <div id="wraper">

    <div id="header">
    Header
    </div>
    <div id="sidebar">
    Side
    </div>
    <div id="content">
    Content
    </div>
    <div id="footer">
    Footer
    </div>

    </div>
    </body>
    </html>

CSS代码:

    #wraper {
    margin:0 auto;
    width:800px;
    height:1000px;
    background:#FCFCFC;
    }
    #header{
    background:#CFCFC0;
    height:100px;
    width:800px;
    }
    #content {
    float:right;
    width:600px;
    height:700px;
    background:#C0C0C4;
    }
    #sidebar {
    float:left;
    width:200px;
    height:700px;
    background:#CFFCCC;
    }
    #footer {
    clear:both;
    background:#C0CC0C;
    height:200px;
    width:800px;
    }
4

5 回答 5

3
*{  
  padding:0; 
  margin:0;
}

padding稍后margin手动给每个标签

于 2012-10-01T09:31:53.577 回答
2

尝试从 body 和 html 元素中删除填充和边距

html, body {
   margin: 0; padding: 0;
}

作为一个好的做法,您可以加载一个normalizereset样式表作为第一个 css(例如http://meyerweb.com/eric/tools/css/reset/)以消除浏览器之间的样式差异

于 2012-10-01T09:31:52.943 回答
0

使用像http://yui.yahooapis.com/2.9.0/build/reset/reset-min.csshttp://meyerweb.com/eric/tools/css/reset/这样的 CSS 重置会有所帮助。

于 2012-10-01T09:33:05.717 回答
0

试试这个演示

仅将其添加到 CSS 的顶部

html, body {
   margin: 0 auto;padding:0;
}

0 表示上边距和下边距,auto 表示左右边距以使其居中

于 2012-10-01T09:46:55.267 回答
0

@Fabrizio 指定的另一个选项是使用规范化 CSS。

https://github.com/necolas/normalize.css/blob/master/normalize.css

于 2015-04-29T07:28:40.410 回答