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

相关推荐
be or not to be8 小时前
深入理解 CSS 浮动布局(float)
前端·css
南山安10 小时前
Tailwind CSS:顺风CSS
javascript·css·react.js
王小菲11 小时前
《网页布局速通:8 大主流方案 + 实战案例》-pink老师现代网页布局总结
css·面试·html
程序员刘禹锡13 小时前
浮动以及导航条和简单布局!!!(12.29日)
css·html·css3
GDAL13 小时前
从零开始上手 Tailwind CSS 教程
前端·css·tailwind
vim怎么退出15 小时前
一次线上样式问题复盘:当你钻进 CSS 牛角尖时,问题可能根本不在 CSS
前端·css
yyf1989052515 小时前
CSS相关中文书籍
css
triumph_passion17 小时前
Tailwind CSS v4 深度指南:目录架构与主题系统
前端·css
JAVA+C语言19 小时前
CSS 继承:核心概念 + 实用解析
前端·css
OpenTiny社区19 小时前
【博文精读】Chrome CSS 2025年回顾
前端·css