学习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.shufengxianlan.com/qtweb/news10/77610.html">学习DIVfloat在ff和ie下的布局区别</a> <br> 网站地址:<a href="http://www.shufengxianlan.com/qtweb/news10/77610.html">http://www.shufengxianlan.com/qtweb/news10/77610.html</a> </p> <p> 网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等 </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="https://www.cdcxhl.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/mobile/">手机网站建设知识</a></p> <ul> <li> <a class="text_overflow" href="/qtweb/news1/149151.html">Linux下的vi编译器:功能强大的代码编辑器(Linuxvi编译器)</a> </li><li> <a class="text_overflow" href="/qtweb/news36/465186.html">10分钟搞定让你困惑的Jenkins环境变量</a> </li><li> <a class="text_overflow" href="/qtweb/news16/393866.html">的所有文件Linux文件夹操作:移动所有文件(如何在linux上移动文件夹里)</a> </li><li> <a class="text_overflow" href="/qtweb/news13/157013.html">怎么开启导航?(怎么开启导航功能)</a> </li><li> <a class="text_overflow" href="/qtweb/news28/112178.html">作者详谈ASP.NETAJA编制模型</a> </li><li> <a class="text_overflow" href="/qtweb/news3/434853.html">VB.NET过程重载使用规则及优点详解</a> </li><li> <a class="text_overflow" href="/qtweb/news35/70985.html">智能媒体服务预览的时候不播放波形图也加载不出来就是一条横线,怎么回事?</a> </li><li> <a class="text_overflow" href="/qtweb/news19/115919.html">皮皮播放器“网络连接失败”错误解决方案</a> </li><li> <a class="text_overflow" href="/qtweb/news49/289499.html">低价美国服务器到底怎么样,可靠吗</a> </li><li> <a class="text_overflow" href="/qtweb/news27/83577.html">日本樱花服务器好吗用?性能如何?</a> </li><li> <a class="text_overflow" href="/qtweb/news49/8099.html">如何实现一次编码,到处运行?新一代云端一体化探索</a> </li><li> <a class="text_overflow" href="/qtweb/news37/183437.html">看到没?10个绝不能放到公共云上的应用</a> </li><li> <a class="text_overflow" href="/qtweb/news6/148206.html">帝国如何生成html</a> </li><li> <a class="text_overflow" href="/qtweb/news9/433159.html">如何在html5里添加定位</a> </li><li> <a class="text_overflow" href="/qtweb/news34/37834.html">【云原生】ApacheLivyonk8s讲解与实战操作</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/snjbc/" 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/jiagu/" 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/zufadianji/" 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/xiangsu/" 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/yhjdsj/" 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/menlian/" 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/xiaojbc/" 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/cantingsj/" 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/baiwuyu/" 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/swzbw/" 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/zaomaoji/" 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/pvc/" target="_blank">PVC花箱</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> </ul> </div> </div> </div> <div class="carousel-inner linkbg" style="background: #fff"> <div class="container"> <a href="http://www.zgwzjz.com/" target="_blank">自贡网站建设</a>    <a href="http://www.njzdgg.com/" target="_blank">内江广告</a>    <a href="http://www.emts.com.cn/about/" target="_blank">德阳东方电机技改服务有限公司</a>    <a href="http://www.gabanjia.cn/" target="_blank">广安搬家公司</a>    <a href="http://www.jinhuajc.com/" target="_blank">橡塑板</a>    <a href="https://www.cdxwcx.com/wangzhan/h5.html" target="_blank">h5页面制作</a>    <a href="http://m.xwcx.net/dianshang/" target="_blank">成都电商解决方案</a>    <a href="https://www.scvps.cn/" target="_blank">申请域名</a>    <a href="http://www.cdkjz.cn/wangzhan/pinpai/" target="_blank">成都品牌网站建设</a>    <a href="http://www.cdxwcx.cn/tuoguan/ershu.html" target="_blank">成都枢纽中心</a>    <a href="https://www.cdcxhl.com/sosuo.html" target="_blank">关键词排名</a>    <a href="http://www.cxjianzhan.com/" target="_blank">成都网站推广</a>    <a href="http://www.cxjianzhan.com/" target="_blank">seo优化</a>    <a href="http://www.cdhuace.com/pinpai.html" target="_blank">广告品牌策划设计</a>    <a href="http://www.idckuai.cn/" target="_blank">注册域名</a>    <a href="http://www.fadianjiwx.cn/" target="_blank">成都发电机维修</a>    <a href="https://www.cdcxhl.cn/ " target="_blank">腾讯云免备案主机</a>    <a href="http://www.bzwzjz.com/" target="_blank">成都网站设计</a>    <a href="https://www.cdxwcx.com/city/guanghan/" target="_blank">广汉网站建设</a>    <a href="http://www.gzruizhi.cn/" 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> 节约开发成本 <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'"> 立即开始2800定制网站建设</button> <button type="button" class="btn btn-default btn-xs" onClick="window.location.href='tencent://message/?uin=631063699&Site=&Menu=yes'"> 2800定制网站建设</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="https://www.cdcxhl.com/" target="_blank">网站设计</a> <a href="https://www.cdcxhl.com/" target="_blank">网站制作</a> <a href="https://www.cdcxhl.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:400-028-6601(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>