学习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.sclezhi.cn/qtweb/news10/77610.html">学习DIVfloat在ff和ie下的布局区别</a> <br> 文章链接:<a href="http://www.sclezhi.cn/qtweb/news10/77610.html">http://www.sclezhi.cn/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/keywordsseo/">关键词优化知识</a></p> <ul> <li> <a class="text_overflow" href="/qtweb/news7/70557.html">利用Redis优化键值存储,给key设置过期时间(redis设置过期key)</a> </li><li> <a class="text_overflow" href="/qtweb/news36/91936.html">保护数据安全重要性:数据库安全控制策略(数据库安全控制)</a> </li><li> <a class="text_overflow" href="/qtweb/news9/107009.html">html导出excel如何设置高度</a> </li><li> <a class="text_overflow" href="/qtweb/news15/103665.html">它是真实的“盗梦空间”?在这里,一切都可能是数据</a> </li><li> <a class="text_overflow" href="/qtweb/news16/101366.html">怎么测试VPS国内速度慢?(vps怎么测试到国内速度慢)</a> </li><li> <a class="text_overflow" href="/qtweb/news40/82340.html">网游服务器租用如何选择</a> </li><li> <a class="text_overflow" href="/qtweb/news21/81121.html">香港云服务器搭建博客业务要注意哪些问题</a> </li><li> <a class="text_overflow" href="/qtweb/news5/87205.html">方差如何求?(方差怎么求)</a> </li><li> <a class="text_overflow" href="/qtweb/news41/104291.html">微信怎样关闭播放功能设置</a> </li><li> <a class="text_overflow" href="/qtweb/news26/62926.html">文件Linux命令行下快捷打开文件的方法(linux命令行怎么打开)</a> </li><li> <a class="text_overflow" href="/qtweb/news29/86379.html">Linux防火墙:保护系统安全的利器(linux中防火墙)</a> </li><li> <a class="text_overflow" href="/qtweb/news21/95671.html">sql注入为什么用</a> </li><li> <a class="text_overflow" href="/qtweb/news34/98584.html">使用Redis队列缓解负担(redis队列减轻负担)</a> </li><li> <a class="text_overflow" href="/qtweb/news13/106663.html">深入浅出Redis架构及其PDF版本(redis架构pdf)</a> </li><li> <a class="text_overflow" href="/qtweb/news27/88477.html">如何解析域名?(dynadot域名怎么设置解析)</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/hwxxy/" 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/jizhuangxiang/" 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/fwqzy/" 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/hgdsj/" 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/muzhiliangting/" 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/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/huaxiang/" 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/jianzhudonghua/" 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/pe/" target="_blank">PE包装袋</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/wsjgd/" 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/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/blgds/" target="_blank">玻璃钢雕塑</a> </li> </ul> </div> </div> </div> <div class="carousel-inner linkbg" style="background: #fff"> <div class="container"> <a href="http://www.cxhljz.cn/" target="_blank">成都网站制作</a>    <a href="https://www.xwcx.net/tuoguan.html" target="_blank">成都IDC机房托管</a>    <a href="http://www.myzwz.com/" target="_blank">绵阳网站制作</a>    <a href="http://m.cdcxhl.cn/seo/ " target="_blank">成都网站优化</a>    <a href="http://www.cxhljz.com/" target="_blank">网站设计制作</a>    <a href="http://seo.cdkjz.cn/" target="_blank">网络推广</a>    <a href="http://www.cdxwcx.cn/tuoguan/zuyong.html" target="_blank">成都服务器租用</a>    <a href="http://www.kswsj.com/" target="_blank">成都网页制作</a>    <a href="https://www.cdcxhl.com/hangyead/" target="_blank">一元广告</a>    <a href="https://www.cdxwcx.com/jifang/leshan.html" target="_blank">四川乐山服务器托管</a>    <a href="http://seo.cdkjz.cn/mobile/" target="_blank">手机网站建设</a>    <a href="http://www.cdxwcx.cn/tuoguan/jianyang.html" target="_blank">简阳机房托管</a>    <a href="http://www.scgulin.cn/" target="_blank">古蔺网站建设</a>    <a href="http://www.cdpanxi.cn/" target="_blank">成都活动策划</a>    <a href="http://www.cdkjz.cn/fangan/finance/" target="_blank">金融行业网站建设方案</a>    <a href="http://www.scghjhjc.com/" target="_blank">广汉锦华建材</a>    <a href="http://www.sczizhong.com/" target="_blank">资中网站建设</a>    <a href="http://www.cdfuwuqi.com/zuyong/" target="_blank">服务器租用</a>    <a href="http://chengdu.cdweb.net/" target="_blank">新网创想</a>    <a href="http://www.cdxwcx.cn/tuoguan/yaan.html" 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>