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...

相关推荐
华仔啊4 小时前
Vue3+CSS 实现的 3D 卡片动画,让你的网页瞬间高大上
前端·css
在云端易逍遥5 小时前
前端必学的 CSS Grid 布局体系
前端·css
进阶的鱼5 小时前
(4种场景)单行、多行文本超出省略号隐藏
前端·css·面试
石金龙20 小时前
[译] Composition in CSS
前端·css
天天扭码21 小时前
来全面地review一下Flex布局(面试可用)
前端·css·面试
用户4582031531721 小时前
CSS特异性:如何精准控制样式而不失控?
前端·css
会豪1 天前
CSS 动画属性精讲:从基础到实战
前端·css
前端Hardy2 天前
HTML&CSS: 谁懂啊!用代码 “擦去”图片雾气
前端·javascript·css
前端Hardy2 天前
HTML&CSS:好精致的导航栏
前端·javascript·css
墨渊君2 天前
“蒙”出花样!用 CSS Mask 实现丝滑视觉魔法
前端·css