This question already has an answer here:
这个问题在这里已有答案:
- A weird spacing appears when I use margin property 3 answers
当我使用margin属性3个答案时,会出现一个奇怪的间距
I want the dark rectangle in the picture below to be completely fit within the window;
我希望下图中的黑色矩形完全适合窗口;
I set margin-left:-8px;
to remove the left margin completely; but what about the right margin?(changing margin-right
doesn't have that effect) how can I remove that too so that the dark rectangle touches the border?
我设置margin-left:-8px;完全去除左边距;但右边距怎么样?(改变边距 - 右边没有那种效果)我怎样才能删除它以使黑暗的矩形接触边框?
my code:
<html>
<head>
<body>
<span style="margin-left:-8px; display:inline-block; width:100%; background:#2F4F4F";><font face="Georgia" size="3" color="#FFFFFF">hello world!</font></span>
</body>
</head>
</html>
4 个解决方案
#1
3
You might want to remove the padding/margin on the html/body elements:
您可能想要删除html / body元素上的填充/边距:
body, html { margin:0; padding:0; }
#2
2
Have you tried:
你有没有尝试过:
body {
padding: 0;
margin: 0;
}
?
#4
2
The body element has a margin of 8px by default. Remove it.
body元素默认为8px的边距。去掉它。
body {
margin:0;
}
#1
3
You might want to remove the padding/margin on the html/body elements:
您可能想要删除html / body元素上的填充/边距:
body, html { margin:0; padding:0; }
#2
2
Have you tried:
你有没有尝试过:
body {
padding: 0;
margin: 0;
}
?
#3
#4
2
The body element has a margin of 8px by default. Remove it.
body元素默认为8px的边距。去掉它。
body {
margin:0;
}