作者都是各自领域经过审查的专家,并撰写他们有经验的主题. 我们所有的内容都经过同行评审,并由同一领域的Toptal专家验证.
Tomislav(硕士)在全栈开发和数据分析方面有超过15年的经验, 但地理空间可视化是他的最爱.
层叠样式表,或 CSS 简而言之,是用标记语言编写的样式表语言. CSS定义了表示, 查看和格式化Web文档的元素, such as the layout, colors and fonts.
CSS语法很全面, 而且总是知道确切的语法并不容易, 或者知道所有可用的CSS属性和相应的值. To help CSS开发者和设计师, Toptal创建了一个快速参考指南,并提供给社区免费下载. CSS参考指南包括CSS语法, 最重要的选择器, properties, sizes and units, 和其他有用的CSS信息,以简短而翔实的格式. 我们希望您会发现CSS小抄表是一个有价值的资源.
您也可以查看Toptal resource pages 有关common的更多信息 CSS mistakes, a CSS hiring guide, CSS面试问题 and CSS技巧和最佳实践. We also offer CSS3 Maker,一个用于快速生成CSS片段的可视化工具.
Syntax |
|
Box Model | ||
/* Comments */ @media type { selector { property: value; } } 注:介质类型可选 | ||||
Inline Style | ||||
Embedded Style
selector { property: value; }
| ||||
External Style Sheet
type = " text / css " href = "风格.css" />
|
Boxes | |||
margin |
margin-top | |||
Selectors |
padding |
padding-top | ||
* |
All elements | |||
tag |
All tag elements |
border |
border-top | |
tag * |
标签内的所有元素 | |||
tag tag2 |
标签内的Tag2元素 |
border-color |
border-top-color | |
tag, tag2 |
所有tag和tag2元素 | |||
tag > tag2 |
Tag2是tag的子元素 |
border-style |
border-top-style | |
tag + tag2 |
tag2 preceded by tag | |||
.class |
类为class的元素 |
border-width |
border-top-width | |
tag.class |
所有带有class ' class '的标签 | |||
#id |
Element with id ‘id’ |
Size and colors | ||
tag#id |
Tag with id ‘id’ |
Relative sizes |
em | rem | ex | ch
Vw | vh | vmin | vmax | % | |
Pseudo-selectors | ||||
:active |
为活动元素添加样式 |
Absolute sizes |
cm | mm | in
px | pt | pc | |
:after |
在元素后添加内容 | |||
:before |
元素前的广告内容 |
Colors |
Hex #ff00ff | |
:first-child |
为第一个子节点添加样式 |
RGB rgb(255,0,255) | ||
:first-letter |
为第一个字符添加样式 |
Positioning | ||
:first-line |
为第一行添加样式 |
position |
绝对|固定|相对|静态|继承 | |
:focus |
为聚焦元素添加样式 | |||
:hover |
鼠标悬停时添加样式 |
float |
左|右| none | inherit | |
:link |
为未访问的链接添加样式 | |||
:visited |
为所访问的链接添加样式 |
top, right, |
设置与边缘的偏移量 | |
Text | ||||
font-family |
指定字体系列。 |
clear |
左|右| both | none | inherit | |
font-size |
指定字体大小。 | |||
font-style |
正常|斜|斜|继承 |
display |
指定元素在文档流中的位置 | |
font-variant |
正常|小盘|继承 |
overflow |
可见|隐藏|滚动|自动|继承 | |
font -weight |
正常|粗体|粗体|轻体| int(100- 900) |继承 | |||
visibility |
可见|隐藏|崩溃|继承 | |||
color |
设置文本的颜色 | |||
line-height |
normal | int | % | inherit |
z-index |
auto | int | inherit | |
text-align |
左|右|中心|证明|继承 |
Dimensions | ||
height |
auto | int | % | inherit | |||
text- decoration |
无| underline | overline | line-through | blink | inherit |
max-height |
none | int | % | inherit | |
max-width |
none | int | % | inherit | |||
text-indent |
int | % | inherit |
min-height |
int | % | inherit | |
text- transform |
无|大写|大写|小写| inherit |
min-width |
int | % | inherit | |
width |
auto | int | % | inherit | |||
vertical -align |
int | % |基线| sub | super | top | text-top middle | bottom | text-bottom |继承 |
Other | ||
background |
Format: 背景(彩色)(图片) (repeat) (position) | |||
white -space |
正常| nowrap | pre | pre-line | pre-wrap|继承 | |||
cursor |
设置光标的类型 | |||
word-spacing |
正常|长度|继承 |
quotes |
设置引号的类型 |
世界级的文章,每周发一次.
世界级的文章,每周发一次.
Join the Toptal® community.