手机
当前位置:查字典教程网 >网页设计 > Div+Css教程 >两种跨浏览器的自适应高的css代码
两种跨浏览器的自适应高的css代码
摘要:好久没发了,今天刚学了点东东,顺便挖过来,happy一下第一种:代码:.div1{width:30%;padding-bottom:3276...

好久没发了 ,今天刚学了点东东,顺便挖过来,happy一下

第一种:代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title></title> <style type="text/css"> .div1{width:30%;padding-bottom:32767px;margin-bottom:-32767px;float:left} .div2{width:40%;padding-bottom:32767px;margin-bottom:-32767px;float:left} .div3{width:30%;padding-bottom:32767px;margin-bottom:-32767px;float:left} </style> </head> <body> <div> <div> 1dd </div> <div> 2 </div> <div> 一<br> 二<br> 三<br> 四<br> 五<br> 六<br> 七<br> 八<br> 九<br> </div> </div> </body> </html>

提示:您可以先修改部分代码再运行

说实话上面一种办法,我根本不理解

第二种方法,比较好理解,

采用相对定位,背景和文字是分离的

代码

<!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> <title>无标题页</title> <style type="text/css"> *{margin:0px; padding:0px; font-size:12px;} #container3 { width:100%; background:red; float:left; position:relative; overflow:hidden; } #container2 { width:100%; background:yellow; float:left; position:relative; right:30%; } #container1 { width:100%; background:green; float:left; position:relative; right:40%; } #container1 .content1 { float:left; width:30%; position:relative; left:70%; white-space:normal; word-break:break-all; overflow:hidden; } #container1 .content2 { float:left; width:40%; position:relative; left:70%; white-space:normal; word-break:break-all; overflow:hidden; } #container1 .content3 { float:left; width:30%; position:relative; left:70%; white-space:normal; word-break:break-all; overflow:hidden; } </style> </head> <body> <div id="container3"> <div id="container2"> <div id="container1"> <div> 撒打发似的发撒打发似的发撒旦法大赛分阿撒打发似的发速度飞洒地方是大夫撒旦法按时打发大沙发是的说法撒旦法撒旦发放撒打发似的发ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc </div> <div> 123 </div> <div> <br>d <br>d <br>d <br>d <br>d <br>d <br>d <br>d <br>d <br>d <br>d <br>d <br>d <br>d 阿撒打发似的发是法师的法师的法师打发的说法大事发生大法师法师法师打发似的发射的反对撒 </div> <div></div> </div> </div> </div> </body> </html>

提示:您可以先修改部分代码再运行

更详细的介绍请看下一篇文章。

【两种跨浏览器的自适应高的css代码】相关文章:

CSS盒模型制定网页的宽度和高度的原理

解决跨浏览器兼容的CSS编码准则

overflow解决float浮动后高度自适应问题

CSS自动控制图片大小的代码

如何用!important解决浏览器兼容性问题

FireFox浏览器和IE浏览器下CSS的兼容问题

多步骤进度条的实现原理及代码

一段巧妙的css debug代码

CSS不同浏览器兼容问题

DIV下图片自适应解决方法

精品推荐
分类导航