flex的一个面试点

flex实现如下布局

html 复制代码
<!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>Document</title>
    <style>
        .flex-box {
            width: 200px;
            height: 200px;
            background-color: green;
            display: flex;
            justify-content: space-between; /*定义项目在主轴上的对齐方式 */

        }
        .flex-item-box {
            width: 50px;
            height: 50px;
            background-color: red;
        }
        .flex-item-box:nth-child(2) {
            align-self: flex-end;
        }
    </style>
</head>
<body>
    <div class="flex-box">
        <div class="flex-item-box"></div>
        <div class="flex-item-box"></div>
    </div>
</body>
</html>

容易被忽视的 align-self

www.ruanyifeng.com/blog/2015/0...

相关推荐
bbq粉刷匠26 分钟前
了解HTML、CSS与JavaScript
javascript·css·html
阳火锅18 小时前
💡 告别类名地狱!Tailwind CSS 语义化转换神器来了
前端·css·vue.js
DFT计算杂谈21 小时前
AMSET 设置多核并行计算
java·前端·css·html·css3
前端老石人1 天前
CSS 值定义语法
前端·css
JYeontu1 天前
正方体翻滚Loading 2.0
前端·javascript·css
唐青枫1 天前
别再手写重复 CSS 了:SCSS 从入门到实战
前端·css·scss
huohaiyu1 天前
HTML和CSS基础使用
前端·css·html
步十人1 天前
【CSS】基础一篇过
前端·css
漂流瓶jz2 天前
从TailwindCSS到UnoCSS:原子化CSS框架接入、特性与配置
前端·css·react.js