css 兩列寬度自適應三種測試例子

來源:互聯網
上載者:User
提示:您可以先修改部分代碼再運行

<!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><style type="text/css">.con{ width:80%; margin:0 auto 10px; border-bottom:2px dashed #333; padding-bottom:10px;}.left,.right{ height:200px; border:1px solid #333; background:#eee;}.left{ width:160px;}.right{ height:400px; background:url(yun_qi_img/logo.gif) no-repeat center center;}.warp{ width:100%; background:#fc3;}/*左側浮動,右側margin-left,IE6,7下在縮小到一定程度右側會下沉,而且有一個 IE6 3px bug*/.con1 .left{ float:left;}.con1 .right{ margin-left:170px; word-break:break-all; _margin-left:167px; /*IE6 3px bug*/}/*左側絕對位置,右側margin-left,此方法有效避免了右側下沉和IE6 3px bug*/.con2{ position:relative;}.con2 .left{ position:absolute; left:0; top:0;}.con2 .right{ margin-left:170px;}/*另外還有網上的一種方法,可能不用確定左側寬度,利用那啥hasLayout原理,不是很明白,但是左側寬度不會計算邊框寬度,在非FF的瀏覽器中寬度過小時會出現右側下沉,而且同樣會有IE6 3px bug*/.con3 .left{ float:left; margin-right:8px; _margin-right:5px; /*IE6 3px bug*/}.con3 .right{ overflow:hidden; word-break:break-all;}</style></head><body><h1>兩列寬度自適應測試</h1><div id="con1" class="con con1" title="左側浮動,右側margin-left,IE6,7下在縮小到一定程度右側會下沉"><div class="left">左側浮動,右側margin-left,IE6,7下在縮小到一定程度右側會下沉,而且有一個 IE6 3px bug</div> <div class="right">Right <div class="warp">測試子項目能否使用width:100%</div> </div></div><div id="con2" class="con con2" title="左側絕對位置,右側margin-left,此方法有效避免了右側下沉和IE6 3px bug"><div class="left">左側絕對位置,右側margin-left,此方法有效避免了右側下沉和IE6 3px bug</div> <div class="right">Right <div class="warp">測試子項目能否使用width:100%</div> </div></div><div id="con3" class="con con3" title="另外還有網上的一種方法,可能不用確定左側寬度,利用那啥hasLayout原理,不是很明白,但是左側寬度不會計算邊框寬度,在非FF的瀏覽器中寬度過小時會出現右側下沉,而且同樣會有IE6 3px bug"><div class="left">另外還有網上的一種方法,可能不用確定左側寬度,利用那啥hasLayout原理,不是很明白,但是左側寬度不會計算邊框寬度,在非FF的瀏覽器中寬度過小時會出現右側下沉,而且同樣會有IE6 3px bug</div> <div class="right">Right <div class="warp">測試子項目能否使用width:100%</div> </div></div></body></html></td> </tr></table>
提示:您可以先修改部分代碼再運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.