CSS 布局之两端布局实现
互联网
20-6-28

<style> * { padding: 0px; margin: 0px; box-sizing: border-box; } .max-box { max-width: 1200px; margin: 0px auto; } .box { overflow: hidden; width: calc(100% + 20px); margin-left: -10px; } .inner { height: 100px; border: solid 1px red; float: left; margin-left: 10px; width: calc(((100% - 20px) - 10px * 3) / 4); } .max-box2 { max-width: 1200px; margin: 50px auto; border: solid 1px red; height: 200px; } </style>再上html
<p class="max-box2"> </p> <p class="max-box"> <p class="box"> <p class="inner"> </p> <p class="inner"> </p> <p class="inner"> </p> <p class="inner"> </p> </p> </p>

最后总结一下那个公式
x = 10px; 即:想要的间距 y = 4 即:想要排列的个数 父级: width: calc(100% + (x * 2)); 子级: width: calc(((100% - (x * 2)) - x * ( y - 1)) / y );
推荐教程:《CSS教程》
以上就是CSS 布局之两端布局实现的详细内容,更多内容请关注技术你好其它相关文章!
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场