Blogger Information
Blog 20
fans 0
comment 0
visits 8466
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1026作业(实例演示flex容器与项目常用属性)
A 管志岗-电商策划
Original
339 people have browsed it

Flex 布局及图示

一、flex 主要两个方向排列

  • flex-direction:主轴由 flex-direction 定义,可以取 4 个值:
    • row 横向排列,从左开始到右,主轴将沿着 inline (列) 方向延伸

      容器宽度够的话,不换行一直往下排,换行的话,往下超出父元素容器的时候就另换行排序
      1、flex-direction: row; 从左到右
      2、flex-direction: row-reverse; 从右到左

    • column 是块排列 主轴会沿着上下方向延伸 — 也就是 block 排列的方向

      flex-direction: column; 从上到下
      flex-direction: column-reverse; 从下到上


二、换行和不换行(元素必须要有width)

  • flex-wrap: nowrap; 不换行,这是默认值
    • flex-wrap: wrap; 换行
  • align-items
    • 属性将直接子节点上的元素 align-self 属性设置项目在其包含块中在交叉轴方向上的对 齐方式
    • stretch: 当前算元素里面自动拉伸,填充剩余空间;
    • start: 交叉轴开始的位置
    • conter: 交叉轴中间位置展示
    • end: 交叉轴结尾位置展示
  • 替换: flex-flow 可以替换 flex-direction 和 flex-wrap
    • 也是主轴方向和不换行
    • flex-flow: row nowrap;

未来学习girt布局,flex布局作为了解,可综合使用

  1. /* place-content: 主轴排列与对齐(通过分配剩余空间实现); */
  2. /* 这是默认 从左到右 */
  3. /* place-content: start; */
  4. /* 这是从右到左 */
  5. /* place-content: end; */
  6. /* 居中排列 */
  7. /* place-content: center; */
  8. /* 两端对齐 */
  9. /* place-content: space-between; */
  10. /* 分散对齐 */
  11. /* place-content: space-around; */
  12. /* 平均对齐 */
  13. /* place-content: space-evenly; */
  14. /* 3. place-items: 交叉轴排列 */
  15. /* 这是默认,自动拉伸 */
  16. /* place-items: stretch; */
  17. /* 这是从上开始 顶部 */
  18. /* place-items: start; */
  19. /* 底部开始 */
  20. /* place-items: end; */
  21. /* 中间开始 */
  22. /* place-items: center; */
  23. /* 因为是单行容器,所以不涉及对齐方式 */
  24. /* flex-direction: column-reverse; */

效果图片

效果图片

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:不错,总结的很好
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!