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

相关推荐
心一信息1 小时前
ThreeJS骨骼示例
css·css3·html5
jason_yang6 小时前
基于BEM规范实现ElementPlus组件
css·scss
@大迁世界1 天前
用 popover=“hint“ 打造友好的 HTML 提示:一招让界面更“懂人”
开发语言·前端·javascript·css·html
伍哥的传说1 天前
Tailwind CSS v4 终极指南:体验 Rust 驱动的闪电般性能与现代化 CSS 工作流
前端·css·rust·tailwindcss·tailwind css v4·lightning css·utility-first
拜无忧1 天前
前端,用SVG 模仿毛笔写字绘画,defs,filter
前端·css·svg
代码小学僧1 天前
🎉 在 Tailwind 中愉快的使用 Antd Design 色彩
前端·css·react.js
ssshooter1 天前
复习 CSS Flex 和 Grid 布局
前端·css·html
菲兹园长1 天前
CSS(展示效果)
前端·javascript·css
UNbuff_01 天前
HTML 中的 CSS 使用说明
css·html·tensorflow
很多石头1 天前
前端img与background-image渲染图片对H5页面性能的影响
前端·css