CSS 速查表
一份可搜索、可打印的 CSS 参考——选择器、盒模型、flexbox、grid、排版、过渡和现代特性。免费。
Selectors
13.class
Select all elements with the class
#id
Select the element with the id
a, b
Group: select a and b
a b
Descendant: b inside a
a > b
Direct child b of a
a + b
Adjacent sibling immediately after a
a ~ b
General sibling b after a
[type="text"]
Attribute selector
:hover :focus
Pseudo-classes for state
:nth-child(2n)
Every even child
::before ::after
Pseudo-elements (generated content)
:not(.x)
Negation: anything but .x
:is(h1, h2, h3)
Matches any selector in the list
Box model
7box-sizing: border-box;
Include padding & border in width
margin: 0 auto;
Center a block horizontally
padding: 1rem 2rem;
Vertical 1rem, horizontal 2rem
border: 1px solid #ccc;
Width, style, color
border-radius: 8px;
Rounded corners
outline: 2px dashed red;
Outline (does not affect layout)
overflow: hidden;
Clip content that overflows
Flexbox
8display: flex;
Create a flex container
flex-direction: row | column;
Main axis direction
justify-content: space-between;
Align along the main axis
align-items: center;
Align along the cross axis
flex-wrap: wrap;
Allow items to wrap
gap: 1rem;
Space between items
flex: 1;
Grow to fill space (1 1 0)
align-self: flex-end;
Override cross-axis for one item
Grid
8display: grid;
Create a grid container
grid-template-columns: 1fr 1fr 1fr;
Three equal columns
repeat(3, 1fr)
Shorthand for repeated tracks
minmax(200px, 1fr)
Track between a min and max
grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
Responsive auto columns
gap: 1rem;
Row and column gap
grid-column: 1 / 3;
Span from line 1 to 3
place-items: center;
Center items on both axes
Typography
8font-family: system-ui, sans-serif;
Font stack
font-size: 1.125rem;
Relative font size
font-weight: 600;
Bold weight
line-height: 1.6;
Line spacing
letter-spacing: .02em;
Tracking
text-align: center;
Horizontal text alignment
text-transform: uppercase;
Change letter case
text-overflow: ellipsis;
Truncate with … (needs overflow+nowrap)
Colors & background
7color: #1f2937;
Text color
background: rgb(0 0 0 / 50%);
Modern rgb with alpha
background: linear-gradient(90deg,#f06,#48f);
Linear gradient
opacity: .5;
Element transparency
box-shadow: 0 4px 12px rgb(0 0 0 / .15);
Drop shadow
background-size: cover;
Scale image to cover
color-mix(in srgb, red 40%, blue);
Mix two colors
Positioning
6position: relative;
Offset from normal position
position: absolute;
Relative to nearest positioned ancestor
position: fixed;
Relative to the viewport
position: sticky; top: 0;
Sticks when scrolling past
inset: 0;
top/right/bottom/left = 0
z-index: 10;
Stacking order
Transitions & animation
5transition: all .2s ease;
Animate property changes
transform: translateY(-4px) scale(1.05);
Move, scale, rotate
@keyframes spin { to { transform: rotate(360deg); } }
Define an animation
animation: spin 1s linear infinite;
Run a keyframe animation
will-change: transform;
Hint the browser to optimize
Responsive & modern
7@media (max-width: 768px) { ... }
Media query breakpoint
clamp(1rem, 2vw, 2rem)
Fluid value with min/max
aspect-ratio: 16 / 9;
Maintain an aspect ratio
var(--brand)
Use a custom property
:root { --brand: #4f46e5; }
Define a custom property
container-type: inline-size;
Enable container queries
@container (min-width: 400px) {…}
Container query
没有条目匹配“:q”。
关于 CSS 速查表
这份 CSS 速查表把你每天都会用到的属性汇集在一个可搜索的页面中:选择器、盒模型、flexbox、grid、排版、颜色与背景、定位、过渡与动画,还有一个关于响应式和现代 CSS 的章节。
它的组织方式让「那个属性叫什么来着?」这个问题只需一次搜索就能解决——flexbox 和 grid 章节尤其列出了对齐和布局属性以及可以直接复制进样式表的取值,现代 CSS 章节则让新特性触手可及。
本速查表免费,客户端加载,随输入实时过滤,并可一键复制任意声明。粘性目录可在各章节间跳转,打印按钮可生成一份整洁的纸质参考表。
如何使用 CSS 速查表
- 浏览章节列表——选择器、盒模型、flexbox、grid、排版等等。
- 在搜索框中输入 grid、hover 或 transition 等属性或概念,即可过滤所有行。
- 通过粘性目录跳转到「定位」等章节。
- 点击代码片段或其复制图标,即可复制该 CSS 声明。
- 打印速查表,作为桌边的 CSS 参考。
常见问题
共九个章节:选择器、盒模型、flexbox、grid、排版、颜色与背景、定位、过渡与动画,以及响应式和现代 CSS 特性。
包含——两者都有各自独立的章节,涵盖容器和子项属性、对齐取值以及简写形式,这些正是开发者最常查阅的内容。
跟得上。除了历久不衰的核心内容之外,专门的响应式与现代 CSS 章节还涵盖了你在当前样式表中会遇到的新特性,以及媒体查询的常见写法。
可以。点击代码或悬停时出现的复制图标,该声明就会进入剪贴板,并有一条简短的"已复制!"提示确认。
是的,完全免费——一个支持实时搜索、无需登录、可无限使用的纯客户端页面。
热门搜索
css 速查表
css 选择器列表
css flexbox 属性
css grid 属性
css 盒模型参考
css position 取值
css 过渡和动画语法
css 属性参考手册
需要帮助?
使用此工具时遇到问题?请告诉我们的团队。