学习DIVfloat在ff和ie下的布局区别

你对DIV float在ff和ie下的布局区别是否了解,这里和大家分享一下,DIV的起始标签和结束标签之间的所有内容都是用来构成这个块的,其中所包含元素的特性由DIV标签的属性来控制,或者是通过使用样式表格式化这个块来进行控制。

创新互联公司是一家专注于网站设计、网站制作与策划设计,梅江网站建设哪家好?创新互联公司做网站,专注于网站建设十载,网设计领域的专业建站公司;建站业务涵盖:梅江等地区。梅江做网站价格咨询:028-86922220

学习DIV float在ff和ie下的布局区别

基本HTML代码
 

 
 
 
 
  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3.  
  4.  
  5.  
  6. DIVFloatSample title> </li> <li> </li> <li><styletypestyletype="text/css">DIV{margin:3px;}.d1{width:250px;min-height:20px;border:1pxsolid#00cc00;}  </li> <li> </li> <li>.d2{width:130px;min-height:40px;border:1pxsolid#0000cc;}  </li> <li> </li> <li>.d3{width:100px;min-height:40px;border:1pxsolid#cc0000;}  </li> <li> </li> <li> style> head> </li> <li> </li> <li><body><DIVclassDIVclass="d1"> </li> <li> </li> <li><DIVclassDIVclass="d2">   </li> <li> </li> <li> DIV><DIVclassDIVclass="d3">   </li> <li> </li> <li> DIV> DIV> body> </li> <li> </li> <li> html> </li> </ol></pre><p>以上代码显示的结果如下,很正常,结果相同。</p></p><p>下面会在这个基础上进行修改,修改的内容都在style中,其他代码就不再重复写了。</p><p>请注意,这里的Style中用到了min-height,这个和height是不同的,min-height指定了对象的一个最小高度,当对象的子内容高度超过这个最小高度是,这个对象会自动撑大。这是一个非常牛的style,可惜的是,在这个style和float这个同样牛的style一起使用的时候,就会出现各种问题。#p#</p><p>◆内部一个DIV修改成为float:left </p> <pre> <ol> <li>.d1{width:250px;min-height:20px;border:1pxsolid#00cc00;}  </li> <li> </li> <li>.d2{width:130px;min-height:40px;border:1pxsolid#0000cc;float:left;}  </li> <li> </li> <li>.d3{width:100px;min-height:40px;border:1pxsolid#cc0000;}  </li> </ol></pre><p>显示结果如下。</p><p>这个结果中,Firefox有点离谱了,两个框叠在一起也就罢了,为什么那个红框会变大捏?而且变的大小也很诡异,不知道是按照什么公式计算出来的。IE在这里的显示应当是附和标准的。</p><p>◆内部两个DIV都修改成为float:left </p> <pre> <ol> <li>.d1{width:250px;min-height:20px;border:1pxsolid#00cc00;}  </li> <li> </li> <li>.d2{width:130px;min-height:40px;border:1pxsolid#0000cc;float:left;}  </li> <li> </li> <li>.d3{width:100px;min-height:40px;border:1pxsolid#cc0000;float:left;}  </li> </ol></pre><p>显示结果如下。</p><p>在这种情况下,Firefox的结果尚能解释,可能是float把外层的DIV也作为内层float影响的范围,这样内层的就不会将外层的DIV撑大了。IE在这里出现了Margin失效的情况,可以解释为内层第二个float造成了影响。#p#</p><p>◆干脆把外层的DIV也修改成为float:left </p> <pre> <ol> <li>.d1{width:250px;min-height:20px;border:1pxsolid#00cc00;float:left;}  </li> <li> </li> <li>.d2{width:130px;min-height:40px;border:1pxsolid#0000cc;float:left;}  </li> <li> </li> <li>.d3{width:100px;min-height:40px;border:1pxsolid#cc0000;float:left;}  </li> </ol></pre><p>显示结果如下。</p><p>这种情况下,Firefox正常了,而IE延续了前面的不正常情况。</p><p>◆外层是float:left,内层最后一个不再float:left </p> <pre> <ol> <li>.d1{width:250px;min-height:20px;border:1pxsolid#00cc00;float:left;}  </li> <li> </li> <li>.d2{width:130px;min-height:40px;border:1pxsolid#0000cc;float:left;}  </li> <li> </li> <li>.d3{width:100px;min-height:40px;border:1pxsolid#cc0000;}  </li> </ol></pre><p>显示结果如下。</p></p><p>这和前面第一种加float:left的情况相同。#p#</p><p><strong>结论</strong></p><p>再重申一次,本文讨论的是一个比较高级的话题。如果在style中用height而不是min-height来设定高度,是不会出现以上这些问题的。不过,不用min-height就失去了DIV自动撑大这一个很有必要的特性。在min-height和float:left的情况下,没有一种完美的写法让Firefox和IE结果相同。不过仍然可以发现绕开的方法。进一步试验可以发现,margin遭到的影响在padding上比较好,所以最好是padding和margin都不用,或者只用padding。</p><p>两者相同的代码如下:</p> <pre> <ol> <li>DIV{padding:3px;}  </li> <li> </li> <li>.d1{width:250px;min-height:20px;border:1pxsolid#00cc00;float:left;}  </li> <li> </li> <li>.d2{width:130px;min-height:40px;border:1pxsolid#0000cc;float:left;}  </li> <li> </li> <li>.d3{width:100px;min-height:40px;border:1pxsolid#cc0000;float:left;}  </li> </ol></pre><p>显示结果如下。</p></p><p>当然所有这些情况也许是有合理解释的,说不定增加某一个style的设置,这些问题都迎刃而解了,不过目前我还没有找到这个设置。</p><p>【编辑推荐】</p> <ol> <li>DIV+CSS中常见十大错误总结</li> <li>DIV定位单元中三大元素的控制</li> <li>深入学习DIV+CSS之绝对定位和相对定位用法</li> <li>Div+CSS布局入门之写入整体层结构与CSS</li> <li>DIV+CSS开发过程中影响SEO的制作细节</li> </ol> <p> 新闻标题:<a href="http://www.kswsj.com/qtweb/news10/77610.html">学习DIVfloat在ff和ie下的布局区别</a> <br> 转载源于:<a href="http://www.kswsj.com/qtweb/news10/77610.html">http://www.kswsj.com/qtweb/news10/77610.html</a> </p> <p> 网站建设、网络推广公司-成都快上网,一家网站设计、网站制作公司;服务项目有等 </p> <p class="adpic"> <a href="https://www.cdcxhl.com/service/ad.html" target="_blank" class="ad">广告</a> <a href="" target="_blank" class="adimg"><img src=""></a> </p> <p class="copy"> 声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: <a href="http://www.kswsj.com/" target="_blank">成都快上网</a> </p> </div> <div class="newsmorelb"> <p>成都快上网科技猜您喜欢</p> <ul> <li> <a href="/qtweb/news9/77609.html">域名购买时间有多久?(域名购买时间有多久的)</a> </li><li> <a href="/qtweb/news8/77608.html">日本云存储服务器租用怎么搭建网站</a> </li><li> <a href="/qtweb/news7/77607.html">安卓怎么反编译</a> </li><li> <a href="/qtweb/news6/77606.html">html中如何对话框</a> </li><li> <a href="/qtweb/news5/77605.html">Linux下开放TCP端口的安全性策略(linuxtcp端口)</a> </li><li> <a href="/qtweb/news4/77604.html">云主机安装系统</a> </li><li> <a href="/qtweb/news3/77603.html">密码让Redis连接变得更加安全默认用户名密码设置(redis连接默认用户名)</a> </li><li> <a href="/qtweb/news2/77602.html">如何进行百度推广优化,百度推广优化技巧分享</a> </li><li> <a href="/qtweb/news1/77601.html">c语言怎么输出矩阵</a> </li> </ul> </div> </div> <div class="col-lg-3 noneb"> <div class="bkright" style="margin-top: 0"> <p><a href="https://www.cdcxhl.com/news/zuo/">做网站知识</a></p> <ul> <li> <a class="text_overflow" href="/qtweb/news9/8409.html">网站空间如何购买</a> </li><li> <a class="text_overflow" href="/qtweb/news34/398834.html">Redis实现对Key的重命名操作(redis重命名key)</a> </li><li> <a class="text_overflow" href="/qtweb/news22/504522.html">群晖中部署php及mssql数据库架构(群晖 php mssql)</a> </li><li> <a class="text_overflow" href="/qtweb/news1/183801.html">域名信息修改,阿里云域名备案信息修改_阿里云的域名备案</a> </li><li> <a class="text_overflow" href="/qtweb/news27/72127.html">老调重弹:年龄大了,码农何去何从</a> </li><li> <a class="text_overflow" href="/qtweb/news5/955.html">1703属于哪个运营商?(windows10企业版1703)</a> </li><li> <a class="text_overflow" href="/qtweb/news46/398846.html">Pandas数据库操作</a> </li><li> <a class="text_overflow" href="/qtweb/news39/394839.html">网站换空间影响SEO?保留原域名拟解决方案</a> </li><li> <a class="text_overflow" href="/qtweb/news42/56492.html">@wraps修饰器:让你的Python代码更加简短可爱|从简单实例来认识它</a> </li><li> <a class="text_overflow" href="/qtweb/news5/186205.html">WiFi密码解码器哪个好?(aircrackngwindows教程)</a> </li><li> <a class="text_overflow" href="/qtweb/news9/155759.html">如何在组织中有效地使用低代码工具?</a> </li><li> <a class="text_overflow" href="/qtweb/news48/340548.html">Redis监测提升系统运行效率(redis 监测工具)</a> </li><li> <a class="text_overflow" href="/qtweb/news39/170989.html">学会代码不是测试的终点而是测试开发的起点</a> </li><li> <a class="text_overflow" href="/qtweb/news0/403650.html">html如何进行超链接</a> </li><li> <a class="text_overflow" href="/qtweb/news12/550762.html">四核服务器:提升服务器运行效率利器(四核服务器)</a> </li> </ul> </div> <div class="bkright tag"> <p><a href="https://www.cdcxhl.com/hangye/" target="_blank">同城分类信息</a></p> <ul> <li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/yangguangfang/" target="_blank">阳光房</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/jszz/" target="_blank">假山制作</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/bdfhw/" target="_blank">被动防护网</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/zhendongpan/" target="_blank">振动盘</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/huisuosj/" target="_blank">会所设计</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/blgzd/" target="_blank">玻璃钢坐凳</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/rxfhw/" target="_blank">柔性防护网</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/lajitong/" target="_blank">垃圾桶</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/hntjbc/" target="_blank">混凝土搅拌罐车</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/zbljbc/" target="_blank">自拌料搅拌车</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/kafeitingsj/" target="_blank">咖啡厅设计</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/bengche/" target="_blank">混凝土泵车</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/jbgc/" target="_blank">搅拌罐车</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/sljbc/" target="_blank">生料搅拌车</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/zsljbc/" target="_blank">自上料搅拌车</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/zzdb/" target="_blank">资质代办</a> </li> </ul> </div> </div> </div> <div class="carousel-inner linkbg" style="background: #fff"> <div class="container"> <a href="http://www.djyfdjwx.com/" target="_blank">威斯达宇</a>    <a href="http://www.nzjierui.cn/" target="_blank">成都柴油发电机组</a>    <a href="http://www.cdxwcx.cn/tuoguan/leshan.html" target="_blank">乐山电信机房</a>    <a href="http://www.scyuzhou.com/" target="_blank">led发光广告字</a>    <a href="https://www.cdxwcx.com/city/luzhou/" target="_blank">泸州网站建设</a>    <a href="http://www.hfwuji.cn/" target="_blank">清舞人间</a>    <a href="http://www.csyarui.cn/" target="_blank">成都雪糕加盟</a>    <a href="https://www.cdcxhl.com/yunying.html" target="_blank">成都网站托管</a>    <a href="http://m.cdcxhl.cn/qiye/ " target="_blank">企业网站建设公司</a>    <a href="http://www.cxhljz.cn/wechat/" target="_blank">微官网开发</a>    <a href="http://www.4006tel.net/" target="_blank">app开发公司</a>    <a href="http://www.dmvi.cn/ser/huace/" target="_blank">成都宣传画册设计</a>    <a href="https://www.scvps.cn/" target="_blank">成都服务器租用</a>    <a href="http://www.hzlinhua.com/" target="_blank">茶叶批发零售</a>    <a href="https://www.cdxwcx.com/city/mianzhu/" target="_blank">绵竹网站建设</a>    <a href="http://www.scmtp.cn/" target="_blank">子晨木包装箱</a>    <a href="http://chengdu.cdcxhl.cn/seo/" target="_blank">成都网站推广</a>    <a href="http://www.czyouth.cn/" target="_blank">混凝土搅拌车</a>    <a href="http://www.scmintian.com/" target="_blank">大邑珉田数据中心</a>    <a href="http://www.ncjike.com/" target="_blank">营山产后护理服务</a>     </div> </div> <footer> <div class="carousel-inner footjz"> <div class="container"> <i class="icon iconfont zbw"></i> 品质网站建设 <i class="icon iconfont"></i> 多平台展现 <i class="icon iconfont"></i> 600元建站 <i class="icon iconfont"></i> 高效快速 <i class="icon iconfont"></i> 专业用心服务 <button type="button" class="btn btn-default btn-lg" onClick="window.location.href='tencent://message/?uin=631063699&Site=&Menu=yes'"> 立即开始600元网站建设</button> <button type="button" class="btn btn-default btn-xs" onClick="window.location.href='tencent://message/?uin=631063699&Site=&Menu=yes'"> 600元企业网站建设</button> </div> </div> <div class="carousel-inner bqsy"> <div class="container"> <div class="lxfs"> <h4 class="yutelnone">028-86922220 13518219792</h4> <h4 class="yutelblock"><a href="tel:02886922220">028-86922220</a> <a href="tel:13518219792">13518219792</a></h4> <a class="btn btn-default" href="tencent://message/?uin=532337155&Site=&Menu=yes" role="button">网站建设<span>QQ</span>:532337155</a> <a class="btn btn-default" href="tencent://message/?uin=631063699&Site=&Menu=yes" role="button">营销推广<span>QQ</span>:631063699</a> <a class="btn btn1 btn-default" href="mqqwpa://im/chat?chat_type=wpa&uin=532337155&version=1&src_type=web&web_src=oicqzone.com" role="button">网站制作<span>QQ</span>:532337155</a> <a class="btn btn1 btn-default" href="mqqwpa://im/chat?chat_type=wpa&uin=631063699&version=1&src_type=web&web_src=oicqzone.com" role="button">营销推广<span>QQ</span>:631063699</a> <a class="btn btn-default nonea" href="tencent://message/?uin=1683211881&Site=&Menu=yes" role="button">售后QQ:1683211881</a> <div class="dz">成都快上网专注: <a href="http://www.kswsj.com/" target="_blank">成都网站制作</a> <a href="http://www.kswsj.com/" target="_blank">网站设计</a> <a href="http://www.kswsj.com/" target="_blank">成都网站建设</a> <address>地址:成都太升南路288号锦天国际A幢10楼</address> </div> </div> <div class="bzdh dz"><img src="https://www.cdcxhl.com/imges/bottom_logo.png" alt="创新互联"> <p><a href="https://www.cdcxhl.com/menu.html" target="_blank">成都创新互联科技有限公司</a><br> Tel:028-86922220(7x24h)</p></div> </div> </div> </footer> </body> </html> <script> $.getJSON ("../../qtwebpic.txt", function (data) { var jsonContent = { "featured":data } var random = jsonContent.featured[Math.floor(Math.random() * jsonContent.featured.length)]; $(".adpic .adimg").attr("href",random.link) $(".adpic img").attr("src",random.pic); }) </script>