Heim  >  Artikel  >  Web-Frontend  >  为什么float:left;但是没有效果_html/css_WEB-ITnose

为什么float:left;但是没有效果_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:42:351973Durchsuche

今天才开始学习html的,但是float:left;却没有效果,不知道我是错哪 了。


<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>css--4</title></head><style type="text/css">div.a{      background:##CCFFFF;	  width:100px;	  height:25px;	  border:5px 15px solid #CCFFCC;	  margin:1px 2px;	  text-align:center;	  color:#999999;	  font-size:15px;	  line-height:22px;	  font-weight:bold;	  float:left;	  }	    div.b{      background:#CCFFFF;	  width:1100px;	  height:25px;	  border:5px solid #CCFFCC;	  margin:1px 2px; }</style><body><div class="a">首页</div><div class="b"></div></body></html>





回复讨论(解决方案)

已浏览器为主

width:1100px; 这个不要

width:1100px; 这个不要


谢谢,确是去掉就好了,但是可以给我讲讲为什么去掉就好了么,我不太理解。。。


width:1100px; 这个不要


谢谢,确是去掉就好了,但是可以给我讲讲为什么去掉就好了么,我不太理解。。。
因为 display:block块的  width 属性的默认值是 auto  就是自动  撑满整行
float 会占用当前行 的一部分    后面一个blockl 如果是auto 那么会尽量在当前行撑满(如果内容宽度没有超出当前行的剩余部分)

上面说的很笼统
细节要自己去找找资料 实际比较复杂


width:1100px; 这个不要


谢谢,确是去掉就好了,但是可以给我讲讲为什么去掉就好了么,我不太理解。。。 谢谢了,我自己再看看,,,,
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn