题目:假设高度已知,请写出三栏布局,其中左栏、右栏各为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.延伸布局