发一个DIV+CSS高度自适应方法网页代码实例
点击次数:31 次 发布日期:2008-11-21 11:00:41 作者:源代码网
|
源代码网推荐源代码网整理以下我今天晚上,做一个快印公司的网站布局,在Div镶套布局中,父标签DIV的高度不变。在IE下没有问题,但是在FIREFOX下就有问题了。 如图:发了两张同样的怕百度盗链,另一张放在我网站上,在教育网内 http://hiphotos.baidu.com/one2two/pic/item/a7c3653de3c3f1de9f3d6295.jpg http://tw.njut.edu.cn/question.gif 代码: <!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=utf-8" /> <title>无标题文档</title> </head> <body> <div style="width:300px;border:#FF0000 solid 1px;"> <div style="width:200px; float:left; position:relative;border:#000000 solid 1px; clear:left"> <p>此处显示</p> <p>新 Div 标签的</p> <p>内容</p> </div> <div style="width:80px; float:left; position:relative;border:#0000CC solid 1px; clear:right">此处显示新 Div 标签的内容</div> </div> </body> </html> 在网上搜索一下发现有同样问题的人还挺多,给的方法也很多,有用JS的,有用HEIGHT=100%的,我感觉都没有作用。
源代码网整理以下我在下面加了一个 <div style="clear:both"></div> 加完后代码是: <!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=utf-8" /> <title>无标题文档</title> </head> <body> <div style="width:300px;border:#FF0000 solid 1px;"> <div style="width:200px; float:left; position:relative;border:#000000 solid 1px; clear:left"> <p>此处显示</p> <p>新 Div 标签的</p> <p>内容</p> </div> <div style="width:80px; float:left; position:relative;border:#0000CC solid 1px; clear:right">此处显示新 Div 标签的内容</div> <div style="clear:both"></div> </div> </body> </html> 这样就可以解决问题了。 源代码网供稿. |