PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

为什么DIV一去边框距离会变_html/css_WEB-ITnose

原创
2016-06-24 12:11:12 1128浏览

我在容器中加入了个headerDIV块,这个块加了边框,与容器边的距离也是刚好按我设定的margin值显示,但是我一把header的边框一去,header这一块就会与容器的上边框空出一段距离,也不知道是为何,求高手指教!


#container{	width:820px; height:100%;	border:1px solid #b58505;	margin:0px auto;}.top{	width:100%; height:52px; font-size:18px;	text-align:right; line-height:40px;	padding-right:20px; margin-left:-10px; margin-top:-10px;	background:url(../images/top.gif) repeat-x;}.top a:hover{ color:red; text-decoration:underline;}.top #srh{ 	vertical-align:top; margin-top:10px;	width:150px; height:18px; border:1px solid gray;}#header{	width:812px; height:303px;	border:1px solid gray;	margin:2px auto 0px;	background:url(../images/header_bg.png) no-repeat center;}


回复讨论(解决方案)

这不加边框空的都应该是一样的,如果不一样也只是差一个边框的厚度

是不是你去掉边框看不出界线在哪里,所以以为空的多了?

问题很多,不细究,除了最外面的层,另外.top同#header层都加一个 float:left; display:inline; 试试

发两个效果的图看看

问题很多,不细究,除了最外面的层,另外.top同#header层都加一个 float:left; display:inline; 试试
可以解决,但是这是为什么呢?

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。