*新闻详情页*/>
1. 定宽 + 自融入
期待实际效果: 左边宽度固定不动, 右边宽度自融入
公共性编码:
html:
<div class="parent"> <div class="left"> <p>left menu</p> </div> <div class="right"> <li>right item1</li> <li>right item2</li> <li>right item3</li> </div> </div>
css:
html, body, p, ul, li { margin: 0; padding: 0; } div.left { background: #d2e3e3; } div.right { background: #77DBDB; }
计划方案1: float
.left { float: left; width: 100px; } .right { margin-left: 100px; // 或 overflow: hidden }
计划方案2: table
.parent { display: table; width: 100%; table-layout: fixed; // https://blog.csdn.net/qq_36699230/article/details/80658742 .left, .right { display: table-cell; } .left { width: 100px; } }
计划方案3: flex
.parent { display: flex; .left { width: 100px; // 或 flex: 0 0 100px; } .right { flex: 1; } }
.parent { display: table; width: 100%; // 设定table-layout: fixed; 会使模块格等宽, 因而此处不设定 .left, .right { display: table-cell; } .left { width: 0.1%; // 宽度设定1个极小值, 因为沒有设定table-layout: fixed; 因此宽度由內容决策 white-space:nowrap; } }
2. 等宽(两/两列)合理布局
公共性编码:
html
<div class="parent"> <div class="column"> <p>1</p> </div> <div class="column"> <p>2</p> </div> <div class="column"> <p>3</p> </div> <div class="column"> <p>4</p> </div> </div>
css
html, body, div, p { margin: 0; padding: 0; } .parent { width: 800px; border: 1px solid coral; .column { height: 30px; background: bisque; p { background: #f0b979; height: 30px; } } }
计划方案1: float (本人其实不喜爱, 写法很死, 必须了解有是多少列, 并且有边框的状况下会超过器皿)
.parent { margin-left: ⑵0px; overflow: hidden; .column { float: left; width: 25%; padding-left: 20px; box-sizing: border-box; } }
计划方案2: flex (强烈推荐)
.parent { display: flex; .column { flex: 1; &+.column { margin-left: 10px; } } }
3. 等高合理布局
强烈推荐计划方案:
.parent { display: flex; } .left, .right { flex: 1; }
以上便是本文的所有內容,期待对大伙儿的学习培训有一定的协助,也期待大伙儿多多适用脚本制作之家。
Copyright © 2002-2020 如何制作微信小游戏_微信游戏小程序_公众号游戏_h5小游戏模板_小程序游戏源码 版权所有 (网站地图) 粤ICP备10235580号