123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>侧轴对齐方式</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- }
- .box {
- display: flex;
- /* 居中 */
- /* align-items: center; */
- /* 拉伸,默认值(现有状态,测试的时候去掉子级的高度) */
- /* align-items: stretch; */
- height: 300px;
- margin: auto;
- border: 1px solid #000;
- }
-
- .box div {
- /* width: 100px; */
- /* height: 100px; */
- background-color: pink;
- }
- /* 单独设置某个弹性盒子的侧轴对齐方式 */
- .box div:nth-child(2) {
- align-self: center;
- }
-
- </style>
- </head>
- <body>
- <div class="box">
- <div>1111</div>
- <div>2</div>
- <div>3</div>
- </div>
- </body>
- </html>
|