Html 如何去除页面左侧和右侧的空白?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23664510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove white space left and right side of page?
提问by Aavik_Kumar
I am trying to make a footer, but the left and right sides show some white space. How to remove the white space?
我正在尝试制作页脚,但左侧和右侧显示一些空白。如何去除空白?
Here is my code:
这是我的代码:
<html>
<head>
<style>
footer {
background: none repeat scroll 0% 0% #DFDFDE;
padding: 120px 0px;
text-align: center;
position: relative;
}
.divider {
background: url('http://evablackdesign.com/wp-content/themes/ebd/images/footer-border.png')
repeat-x scroll center center transparent;
height: 7px;
width: 100%;
position: absolute;
top: -6px;
}
.container {
width: 930px;
margin: 0px auto;
}
</style>
</head>
<body>
<footer>
<div class="divider"></div>
<div class="container">
<h1>hiiiiiiiii</h1>
<br>
<h2>buyyyyyyyyyyyy</h2>
</div>
</footer>
</body>
</html>
The tag defines a footer for a document or section.
该标签定义文档或部分的页脚。
A element should contain information about its containing element.
元素应包含有关其包含元素的信息。
A footer typically contains the author of the document, copyright information, links to terms of use, contact information, etc.
页脚通常包含文档的作者、版权信息、使用条款的链接、联系信息等。
回答by j08691
The body has a default margin. Remove it via:
正文有一个默认的边距。通过以下方式删除它:
html,body {
margin:0;
padding:0;
}
回答by Mayank
Most Web browsers have different default settings for the base margins and padding. This means that if you don't set a margin and padding on your body and html tags, you could get inconsistent results on the page depending upon which browser you're using to view the page.
大多数 Web 浏览器对基本边距和填充有不同的默认设置。这意味着,如果您没有在 body 和 html 标签上设置边距和内边距,根据您用于查看页面的浏览器,您可能会在页面上获得不一致的结果。
The best way to solve this is to set all the margins and paddings on the html and body tags to 0:
解决此问题的最佳方法是将 html 和 body 标签上的所有边距和内边距设置为 0:
html, body {
margin: 0px;
padding: 0px;
}
回答by Ranjan
*{
width: 100%;
height: 100%;
padding: 0px;
margin: 0px;
overflow-x: hidden;
}
回答by Pedro
Add this to your style tag...
将此添加到您的样式标签...
body {
margin: 0;
}