題目:假設高度已知,請寫出三欄佈局,其中左欄、右欄各爲300px,中間自適應。css
<style media="screen"> html *{ padding: 0; margin: 0; } .layout{ margin-top: 20px; } .layout article div{ min-height: 100px; } </style>
<!--浮動佈局--> <section class="layout float"> <style media="screen"> .layout.float .left{ float: left; width: 300px; background-color: red; } .layout.float .right{ float: right; width: 300px; background-color: red; } .layout.float .center{ background-color: blue; } </style> <article class="left-right-center"> <div class="left"></div> <div class="right"></div> <div class="center"> <h1>浮動解決方案</h1> 1.這是三欄佈局的中間部分 2.這是三欄佈局的中間部分 3.這是三欄佈局的中間部分 4.這是三欄佈局的中間部分 5.這是三欄佈局的中間部分 6.這是三欄佈局的中間部分 </div> </article> </section>
<!--絕對佈局--> <section class="layout absolute"> <style> .layout.absolute .left-center-right>div{ position: absolute; } .layout.absolute .left{ left: 0; width: 300px; background-color: red; } .layout.absolute .center{ left: 300px; right: 300px; background-color: blue; } .layout.absolute .right{ right: 0; width: 300px; background-color: red; } </style> <article class="left-center-right"> <div class="left"></div> <div class="center"> <h1>絕對定位解決方案</h1> 1.這是三欄佈局的中間部分 2.這是三欄佈局的中間部分 3.這是三欄佈局的中間部分 4.這是三欄佈局的中間部分 5.這是三欄佈局的中間部分 6.這是三欄佈局的中間部分 </div> <div class="right"></div> </article> </section>
<!--flexbox佈局--> <section class="layout flexbox"> <style> .layout.flexbox{ margin-top: 140px; } .layout.flexbox .left-center-right{ display: flex;/*聲明此容器是flexbox佈局*/ } .layout.flexbox .left{ width: 300px; background-color: red; } .layout.flexbox .center{ flex: 1;/*此部分自適應*/ background-color: blue; } .layout.flexbox .right{ width: 300px; background-color: red; } </style> <article class="left-center-right"> <div class="left"></div> <div class="center"> <h1>flexbox解決方案</h1> 1.這是三欄佈局的中間部分 2.這是三欄佈局的中間部分 3.這是三欄佈局的中間部分 4.這是三欄佈局的中間部分 5.這是三欄佈局的中間部分 6.這是三欄佈局的中間部分 </div> <div class="right"></div> </article> </section>
<!-- 表格佈局 --> <section class="layout table"> <style> .layout.table .left-center-right{ width: 100%; display: table; height: 100px; } .layout.table .left-center-right>div{ display: table-cell; } .layout.table .left{ width: 300px; background-color: red; } .layout.table .center{ background-color: blue; } .layout.table .right{ width: 300px; background-color: red; } </style> <article class="left-center-right"> <div class="left"></div> <div class="center"> <h1>表格佈局解決方案</h1> 1.這是三欄佈局的中間部分 2.這是三欄佈局的中間部分 3.這是三欄佈局的中間部分 4.這是三欄佈局的中間部分 5.這是三欄佈局的中間部分 6.這是三欄佈局的中間部分 </div> <div class="right"></div> </article> </section>
<!-- 網格佈局 --> <section class="layout grid"> <style> .layout.grid .left-center-right{ display: grid; width: 100%; grid-template-rows:100px; grid-template-columns:300px auto 300px; } .layout.grid .left{ background-color: red; } .layout.grid .center{ background-color: blue; } .layout.grid .right{ background-color: red; } </style> <article class="left-center-right"> <div class="left"></div> <div class="center"> <h1>網格佈局解決方案</h1> 1.這是三欄佈局的中間部分 2.這是三欄佈局的中間部分 3.這是三欄佈局的中間部分 4.這是三欄佈局的中間部分 5.這是三欄佈局的中間部分 6.這是三欄佈局的中間部分 </div> <div class="right"></div> </article> </section>
1.五種方案優缺點?html
2.假設高度不肯定,根據中間文字自適應,哪一個適用?css3
3.5種方案的兼容性如何?最優方案是哪一個?
4.延伸佈局