博客列表 >flex术语

flex术语

牙森江
牙森江原创
2022年10月27日 17:09:34422浏览

1.flex术语

1.1 flex容器

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. .demo {
  10. display: flex;
  11. width: 40rem;
  12. height:20rem ;
  13. background-color: rgb(209, 251, 143);
  14. }
  15. .demo > .item {
  16. width: 8rem;
  17. height: 15rem;
  18. background-color: rgb(153, 195, 230);
  19. border: 0.1rem solid black;
  20. margin-left: 0.1rem;
  21. text-align: center;
  22. line-height: 15rem;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <div class="demo">
  28. <div class="item">01</div>
  29. <div class="item">02</div>
  30. <div class="item">03</div>
  31. <div class="item">04</div>
  32. </div>
  33. </body>
  34. </html>

代码运行效果如下:

" class="reference-link">

1.2flex容器子元素交叉轴和主轴排列方法

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. .demo {
  10. display: flex;
  11. width: 40rem;
  12. height:20rem ;
  13. background-color: rgb(209, 251, 143);
  14. place-content: space-between; /*两端对齐 (掌握)*/
  15. place-content: space-around; /*分散对齐(掌握)*/
  16. place-content: space-evenly; /*平均对齐 (掌握)*/
  17. /* 交叉轴 */
  18. /* place-items: stretch; */
  19. /* place-items: start; */
  20. place-items: center;
  21. /* place-items: end; */
  22. }
  23. .demo > .item {
  24. width: 8rem;
  25. height: 15rem;
  26. background-color: rgb(153, 195, 230);
  27. border: 0.1rem solid black;
  28. margin-left: 0.1rem;
  29. text-align: center;
  30. line-height: 15rem;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <div class="demo">
  36. <div class="item">01</div>
  37. <div class="item">02</div>
  38. <div class="item">03</div>
  39. <div class="item">04</div>
  40. </div>
  41. </body>
  42. </html>

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议