align-self属性允许单个项目有与其他项目不一样的对齐方式,可覆盖align-items属性。默认值为auto,表示继承父元素的align-items属性,如果没有父元素,则等同于stretch,
用法:
div span:nth-child(3) {
align-self: flex-end;
}

例子

  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. div {
  10. display: flex;
  11. width: 500px;
  12. height: 200px;
  13. background-color: blue;
  14. justify-content: center;
  15. }
  16. div span {
  17. width: 100px;
  18. height: 100px;
  19. background-color: red;
  20. }
  21. div span:nth-child(3) {
  22. align-self: flex-end;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <div>
  28. <span>1</span>
  29. <span>1</span>
  30. <span>1</span>
  31. </div>
  32. </body>
  33. </html>

image.png