博主信息
博文 11
粉丝 0
评论 0
访问量 12559
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
flex容器常用的四个属性
酿酒的人ァ
原创
790人浏览过
  • flex-flow: 设置主轴的方向和项目在主轴的换行方式
  • justify-content: 项目在主轴的对齐方式
  • align-items: 项目在交叉轴上的对齐方式
  • align-content: 设置项目在多行容器中的对齐方式

代码实例:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>实例演示:flex容器常用的四个属性</title>
  7. <style>
  8. * {
  9. box-sizing: border-box;
  10. }
  11. .container {
  12. height: 15em;
  13. border: 1px solid coral;
  14. padding: 1em;
  15. margin: 1em;
  16. display: flex;
  17. }
  18. .container > .item {
  19. width: 8em;
  20. background-color: lightyellow;
  21. border: 1px solid chocolate;
  22. }
  23. .container {
  24. flex-flow: row nowrap;
  25. flex-flow: row wrap;
  26. }
  27. /* .container {
  28. flex-flow: column nowrap;
  29. flex-flow: column wrap;
  30. flex-flow: column wrap-reverse;
  31. height: 8em;
  32. } */
  33. .container {
  34. justify-content: flex-start;
  35. justify-content: flex-end;
  36. justify-content: flex-end;
  37. justify-content: center;
  38. justify-content: space-between;
  39. justify-content: space-around;
  40. justify-content: space-evenly;
  41. }
  42. .container {
  43. flex-flow: row nowrap;
  44. align-items: stretch;
  45. align-items: flex-start;
  46. align-items: flex-end;
  47. align-items: center;
  48. }
  49. /.container {
  50. flex-flow: row wrap;
  51. align-content: stretch;
  52. align-content: flex-end;
  53. align-content: flex-start;
  54. align-content: center;
  55. align-content: space-around;
  56. align-content: space-between;
  57. align-content: space-evenly;
  58. }
  59. </style>
  60. </head>
  61. <body>
  62. <div class="container">
  63. <div class="item">item1</div>
  64. <div class="item">item2</div>
  65. <div class="item">item3</div>
  66. <div class="item">item4</div>
  67. <div class="item">item5</div>
  68. <div class="item">item6</div>
  69. <div class="item">item7</div>
  70. <div class="item">item8</div>
  71. </div>
  72. </body>
  73. </html>
批改老师:天蓬老师天蓬老师

批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学