1.flex-direction:row 默认从左向右

image.png

  1. .box{
  2. width: 200px;
  3. height: 200px;
  4. border: 1px solid red;
  5. margin: 100px auto;
  6. display: flex;
  7. flex-direction:row
  8. }
  9. .box span{
  10. display: inline-block;
  11. width: 30px;
  12. height: 30px;
  13. background-color: pink;
  14. border-radius: 50%;
  15. }
  16. <div class="box">
  17. <span>1</span>
  18. <span>2</span>
  19. <span>3</span>
  20. </div>

2.flex-direction:row-reverse 从右到左

image.png

  1. .box{
  2. width: 200px;
  3. height: 200px;
  4. border: 1px solid red;
  5. margin: 100px auto;
  6. display: flex;
  7. flex-direction:row-reverse;
  8. }
  9. .box span{
  10. display: inline-block;
  11. width: 30px;
  12. height: 30px;
  13. background-color: pink;
  14. border-radius: 50%;
  15. }

3.flex-direction:column 从上到下

image.png

  1. .box{
  2. width: 200px;
  3. height: 200px;
  4. border: 1px solid red;
  5. margin: 100px auto;
  6. display: flex;
  7. flex-direction:column;
  8. }
  9. .box span{
  10. display: inline-block;
  11. width: 30px;
  12. height: 30px;
  13. background-color: pink;
  14. border-radius: 50%;
  15. }

4.flex-direction:column-reverse 从下到上—>

image.png

  1. .box{
  2. width: 200px;
  3. height: 200px;
  4. border: 1px solid red;
  5. margin: 100px auto;
  6. display: flex;
  7. flex-direction:column-reverse;
  8. }
  9. .box span{
  10. display: inline-block;
  11. width: 30px;
  12. height: 30px;
  13. background-color: pink;
  14. border-radius: 50%;
  15. }