公告:“业余草”微信公众号提供免费CSDN下载服务(只下Java资源),关注业余草微信公众号,添加作者微信:xttblog2,发送下载链接帮助你免费下载!
本博客日IP超过2000,PV 3000 左右,急需赞助商。
极客时间所有课程通过我的二维码购买后返现24元微信红包,请加博主新的微信号:xttblog2,之前的微信号好友位已满,备注:返现
受密码保护的文章请关注“业余草”公众号,回复关键字“0”获得密码
所有面试题(java、前端、数据库、springboot等)一网打尽,请关注文末小程序
腾讯云】1核2G5M轻量应用服务器50元首年,高性价比,助您轻松上云
本博客日IP超过2000,PV 3000 左右,急需赞助商。
极客时间所有课程通过我的二维码购买后返现24元微信红包,请加博主新的微信号:xttblog2,之前的微信号好友位已满,备注:返现
受密码保护的文章请关注“业余草”公众号,回复关键字“0”获得密码
所有面试题(java、前端、数据库、springboot等)一网打尽,请关注文末小程序

腾讯云】1核2G5M轻量应用服务器50元首年,高性价比,助您轻松上云
Bootstrap 4 (Beta)中已经正式采用了 flexbox 网格系统。可以预见 flexbox 布局在不久的将来将越来越受欢迎。
本文将结合作者个人的经验和理解整了这部分教程,希望对大家有所帮助。
下面先从 flex 容器元素相关属性开始讲起。
flex-direction:flex布局方向
row:行布局
.flex-container.flex-row{ -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; } .flex-container.row-reverse{ -webkit-flex-direction: row-reverse; -ms-flex-direction: row-reverse; flex-direction: row-reverse; } .flex-container.flex-column{ -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; height: 150px; } .flex-container.column-reverse{ -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column-reverse; height: 150px; }
row-reverse:颠倒行布局
column:列布局
column-reverse:颠倒列布局
flex-wrap:包布局
.contenedor { flex-wrap: nowrap | wrap | wrap-reverse; }
flex-wrap有三个取值,nowrap | wrap | wrap-reverse。它们的效果分别如下:
align-items布局
.contenedor { align-items: flex-start | flex-end | center | baseline | stretch; }
justify-content布局
.contenedor { justify-content: flex-start | flex-end | center | space-between | space-around; }
align-content 布局
.contenedor { align-content: flex-start | flex-end | center | space-between | space-around | stretch; }
align-self 布局
.item { align-self: flex-start | flex-end | center | baseline | stretch; }
flex-grow 布局
.item { flex: flex-grow [flex-shrink] [flex-basis]; }
flex-grow、flex-shrink 和 flex 以及 order 布局都类似。
参考资料
- http://w3.unpocodetodo.info/css3/flex-direction.php
- http://w3.unpocodetodo.info/css3/flex-wrap.php
- http://w3.unpocodetodo.info/css3/flex-align-items.php
- http://w3.unpocodetodo.info/css3/flex-justify-content.php
- http://w3.unpocodetodo.info/css3/flex-align-content.php
- http://w3.unpocodetodo.info/css3/flex-align-self.php
- http://w3.unpocodetodo.info/css3/flex-abreviado.php
最后,欢迎关注我的个人微信公众号:业余草(yyucao)!可加作者微信号:xttblog2。备注:“1”,添加博主微信拉你进微信群。备注错误不会同意好友申请。再次感谢您的关注!后续有精彩内容会第一时间发给您!原创文章投稿请发送至532009913@qq.com邮箱。商务合作也可添加作者微信进行联系!
本文原文出处:业余草: » Flexbox(网格系统)布局教程