| 发表于:2007-05-11 14:03:141楼 得分:0 |
<div id= "b "> 中你用了float:left, <div id= "m> 跟在后面,他会用左对齐或右对齐的方式跟着,你你的容器,#wrap只有750px,所以不显示了,在#m 上加下clear:both;就ok了,意思清除前面的样式 这下面的代码只在ie6.0试了下,你看看行了不 ------------------------------------------------------------- <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en " "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd "> <html xmlns= "http://www.w3.org/1999/xhtml "> <head> <meta http-equiv= "content-type " content= "text/html; charset=gb2312 " /> <title> 浮动同时改变宽度对相邻绝对定位元素显示的影响 </title> <style type= "text/css "> <!-- * {margin:0px; padding:0px;} body { height:100%; } div{ border: 1px solid yellow; } #wrap{ background-color:#c0c0c0; height:100%; width:750px; } #b{ float:left;/*无论是左浮动还是右浮动结果都一样*/ width:755px;/*该内容宽度一超过745像素就导致#m消失*/ height:50px; background-color:#cd5c5c; } #m{ clear:both; width:20px; height:10px; position:absolute; top:50px; left:10px; background:#6ef; display:block; } --> </style> </head> <body> <div id= "wrap "> <div id= "b "> </div> <div id= "m "> </div> <!--无论#m在#b前还是在#b后都会得到相同后果--> </div> </body> </html> | | |
|