作者都是各自领域经过审查的专家,并撰写他们有经验的主题. 我们所有的内容都经过同行评审,并由同一领域的Toptal专家验证.
托米斯拉夫·巴辛格的头像

Tomislav Bacinger

Tomislav(硕士)在全栈开发和数据分析方面有超过15年的经验, 但地理空间可视化是他的最爱.

Share

层叠样式表,或 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片段的可视化工具.

下载CSS小抄

点击这里下载CSS小抄

CSS Cheat Sheet

<风格type = " text / css " > table { width: 100% } table td, table th { padding: 0; border: none; font-family: monospace; } .c4 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; background-color: #eff4f9; width: 63pt; } .c21 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; background-color: #eff4f9; width: 148.5pt; } .c6 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; background-color: #3dbe8b; width: 148.5pt; } .c22 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; background-color: #eff4f9; width: 48%; } .c10 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; background-color: #fafbfc; width: 63pt; } .c7 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; background-color: #eff4f9; width: 138.8pt; } .c11 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; background-color: #3dbe8b; width: 219.8pt; } .c13 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; background-color: #fafbfc; width: 148.5pt; } .c2 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; width: 4%; } .c14 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; width: 81pt; } .c20 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; width: 138.8pt; } .c31 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; width: 48%; } .c32 { padding: 5pt 5pt 5pt 5pt; vertical-align: top; width: 219.8pt; } .c39 { color: #000000; font-weight: normal; text-decoration: none; vertical-align: baseline; font-size: 11pt; font-style: normal } .c27 { color: #000000; font-weight: normal; text-decoration: none; vertical-align: baseline; font-size: 9pt; font-style: normal } .c1 { color: #000000; font-weight: normal; text-decoration: none; vertical-align: baseline; font-size: 9pt; font-style: normal } .c15 { color: #000000; font-weight: normal; text-decoration: none; vertical-align: baseline; font-size: 9pt; font-style: normal } .c30 { color: #ffffff; font-weight: normal; text-decoration: none; vertical-align: baseline; font-style: normal } .c18 { color: #000000; font-weight: normal; text-decoration: none; vertical-align: baseline; font-style: italic } .c24 { color: #ffffff; font-weight: bold; text-decoration: none; vertical-align: baseline; font-style: normal } .c19 { border-spacing: 0; border-collapse: collapse; margin-right: auto } .c41 { padding-top: 0pt; padding-bottom: 0pt; line-height: 1.0; text-align: right; font-size: 9pt !important; } .c0 { padding-top: 0pt; padding-bottom: 0pt; line-height: 1.0; text-align: left; margin-bottom: 0 !important; font-size: 1em !important; } .c42 { padding-top: 0pt; padding-bottom: 0pt; line-height: 1.0 } .c35 { background-color: #ffffff; max-width: 468pt; padding: 72pt 72pt 72pt 72pt } .c25 { color: #ffffff; font-weight: bold } .c12 { color: #1155cc; text-decoration: underline } .c28 { orphans: 2; widows: 2 } .c8 { margin: 5px } .c33 { font-size: 7pt; } .c34 { page-break-after: avoid; text-align: center } .c17 { font-size: 9pt; } .c177 { font-family: "Proxima Nova",Arial,sans-serif; } .c9 { color: inherit; text-decoration: inherit } .c36 { margin-right: -0.8pt } .c23 { background-color: #eff4f9 } .c40 { font-size: 9pt } .c3 { height: 19pt } .c37 { height: 21pt } .c29 { background-color: #3dbe8b } .c38 { text-align: center } .c26 { font-style: italic } .c16 { background-color: #fafbfc } .c5 { height: 11pt }

Syntax

Box Model

/* Comments */

@media type {

  selector {

    property: value;

  }

}

注:介质类型可选

CSS Box Model

Inline Style

 

Embedded Style

 

   

 

External Style Sheet

 

   

     type = " text / css " href = "风格.css" />

 

Boxes

margin

margin-top
margin-right
margin-bottom
margin-left

Selectors

padding

padding-top
padding-right
padding-bottom
padding-left

*

All elements

tag

All tag elements

border

border-top
border-right
border-bottom
border-left

tag *

标签内的所有元素

tag tag2

标签内的Tag2元素

border-color

border-top-color
border-right-color
border-bottom-color
border-left-color

tag, tag2

所有tag和tag2元素

tag > tag2

Tag2是tag的子元素

border-style

border-top-style
border-right-style
border-bottom-style
border-left-style

tag + tag2

tag2 preceded by tag

.class

类为class的元素

border-width

border-top-width
border-right-width
border-bottom-width
border-left-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,
bottom, left

设置与边缘的偏移量

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

设置引号的类型

就这一主题咨询作者或专家.
Schedule a call

世界级的文章,每周发一次.

订阅意味着同意我们的 privacy policy

世界级的文章,每周发一次.

订阅意味着同意我们的 privacy policy

Toptal Developers

Join the Toptal® community.