删除div左上角和右上角的空间 [英] Removing space at the top left and right of div
问题描述
我开始使用css并有基本问题。
I am starting to work with css and have basic issue.
我有一个div元素:
.top {
background-color: #3B5998;
margin-left: 0px;
margin-top: 0px
}
<div class="top">...</div>
颜色代码正在生效(好)。
The colour code is taking effect (good).
我遇到的问题是,在图片的左边,右上角有一些 div 。如何摆脱白色空间?例如,如果你看看Facebook页面,顶部是完全蓝色,在顶部没有空白。
The problem I have is that there seems to be a bit of white space on left, top and right of the div. How do I get rid of the white space? For example if you take a look at Facebook page, the top part is completely blue, there is no white space at the top.
推荐答案
您需要重置样式表中的默认填充和边距属性:
You need to reset both the default padding and margin attributes in your stylesheet:
html, body {
margin: 0;
padding: 0;
}
$ b $ p
正如@Jason McCreary提到的,您还应该考虑使用重置样式表。他链接到的一个,Eric Meyer的CSS重置,是一个很好的开始。
As @Jason McCreary mentions, you should also look into using a reset stylesheet. The one he links to, Eric Meyer's CSS reset, is a great place to start.
它看起来像你在你的CSS中缺少一个分号,应如下所示:
It also looks like you're missing a semi-colon in your css, it should look as follows:
.top
{
background-color:#3B5998;
margin-left:0px;
margin-top:0px;
}
这篇关于删除div左上角和右上角的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!