CSS 速查表

常用属性、布局与选择器

用法 说明
display: flex 弹性布局
flex-direction: row|column 主轴方向
justify-content: center|space-between 主轴对齐
align-items: center|stretch 交叉轴对齐
flex-wrap: wrap 换行
display: grid 网格布局
grid-template-columns: repeat(n, 1fr) 网格列定义
gap: 1rem 间距(flex/grid)
position: relative|absolute|fixed|sticky 定位
top|right|bottom|left 定位偏移
margin: auto 水平居中
padding: 1rem 内边距
width: 100%|50vw|100px 宽度单位
box-sizing: border-box 盒模型
:hover :focus :active 常用伪类
::before ::after 伪元素
transition: all 0.3s 过渡动画
transform: translate() rotate() scale() 变换
@media (min-width: 768px) 媒体查询