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

相关推荐
AAA阿giao14 小时前
从零构建一个现代登录页:深入解析 Tailwind CSS + Vite + Lucide React 的完整技术栈
前端·css·react.js
掘金安东尼1 天前
用 CSS 打造完美的饼图
前端·css
掘金安东尼1 天前
纯 CSS 实现弹性文字效果
前端·css
前端Hardy2 天前
HTML&CSS&JS:打造丝滑的3D彩纸飘落特效
前端·javascript·css
前端Hardy2 天前
HTML&CSS&JS:丝滑无卡顿的明暗主题切换
javascript·css·html
parade岁月3 天前
Tailwind CSS v4 — 当框架猜不透你的心思
前端·css
前端Hardy3 天前
HTML&CSS&JS:基于定位的实时天气卡片
javascript·css·html
程序员阿耶3 天前
5 个让 CSS 起飞的新特性,设计师看了直呼内行
css
前端Hardy3 天前
HTML&CSS:纯CSS实现随机转盘抽奖机——无JS,全靠现代CSS黑科技!
css·html
漂流瓶jz3 天前
BEM、OOCSS、SMACSS、ITCSS、AMCSS、SUITCSS:CSS命名规范简介
前端·css·代码规范