CSS

CSS

background

  • background
  • background-color
  • background-image
  • background-repeat
  • background-attachment
  • background-position

text

  • color
  • text-align
  • vertical-align
  • text-decoration
  • text-transform
  • text-indent
  • direaction
  • unicode-bidi
  • letter-spacing
  • line-height
  • text-shadow
  • white-space
  • word-spacing

fonts

  • font
  • font-style
  • font-variant
  • font-weight
  • font-size/line-height
  • font-family
  • a:link
  • a:visited
  • a:hover
  • a:active

list-ul-ol-li

  • list-style
  • list-style-type
  • list-style-position
  • list-style-image

table

  • border-collapse

box model

  • margin
  • border
  • padding
  • content

border

  • border
  • border-width
  • border-style
  • border-color
  • border-bottom
  • border-bottom-color
  • border-bottom-style
  • border-bottom-width
  • border-left
  • border-left-color
  • border-left-style
  • border-left-width
  • border-right
  • border-right-color
  • border-right-style
  • border-right-width
  • border-top
  • border-top-color
  • border-top-style
  • border-top-width
  • border-radius

outline

  • outline
  • outline-color
  • outline-style
  • outline-width

margin

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

padding

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

dimension

  • height
  • width
  • line-height
  • max-height
  • max-width
  • min-height
  • min-width

display/visibility

  • display:none
  • display:inline
  • display:block
  • visibility:none
  • visibility:collapse

position

  • position:static
  • position:relative
  • position:fixed
  • position:absolute
  • position:sticky
  • top
  • right
  • bottom
  • left
  • clip
  • cursor
  • z-index

overflow

  • visible
  • hidden
  • scroll
  • auto
  • inherit

float

  • float:right
  • float:left
  • float:none
  • float:inherit
  • clear:left/right/both/none/inherit

对齐

  • 水平居中
    • margin:auto 水平对齐,没有width不起作用
    • text-align:center 文本居中对齐
    • position:absolute 搭配位置属性
    • float:right
  • 垂直居中
    • padding:10px 0
    • line-height
    • position:absolute 父元素也要有position,否则就是相对于body
    • transform:translate(-50%, -50%)

组合选择器

  • 后代用空格
  • 子元素用>
  • 相邻兄弟选择器用+
  • 后续兄弟选择器用~

伪类

  • a:hover
  • a.red:visited
  • p:first-child
  • q:lang(no)
  • :checked
  • :disabled
  • :empty
  • :enabled
  • :first-of-type
  • :in-range input:in-range 选择元素指定范围内的值 :invalid input:invalid 选择所有无效的元素 :last-child p:last-child 选择所有p元素的最后一个子元素 :last-of-type p:last-of-type 选择每个p元素是其母元素的最后一个p元素 :not(selector) :not(p) 选择所有p以外的元素 :nth-child(n) p:nth-child(2) 选择所有 p 元素的父元素的第二个子元素 :nth-last-child(n) p:nth-last-child(2) 选择所有p元素倒数的第二个子元素 :nth-last-of-type(n) p:nth-last-of-type(2) 选择所有p元素倒数的第二个为p的子元素 :nth-of-type(n) p:nth-of-type(2) 选择所有p元素第二个为p的子元素 :only-of-type p:only-of-type 选择所有仅有一个子元素为p的元素 :only-child p:only-child 选择所有仅有一个子元素的p元素 :optional input:optional 选择没有"required"的元素属性 :out-of-range input:out-of-range 选择指定范围以外的值的元素属性 :read-only input:read-only 选择只读属性的元素属性 :read-write input:read-write 选择没有只读属性的元素属性 :required input:required 选择有"required"属性指定的元素属性 :root root 选择文档的根元素 :target #news:target 选择当前活动#news元素(点击URL包含锚的名字) :valid input:valid 选择所有有效值的属性 :link a:link 选择所有未访问链接 :visited a:visited 选择所有访问过的链接 :active a:active 选择正在活动链接 :hover a:hover 把鼠标放在链接上的状态 :focus input:focus 选择元素输入后具有焦点 :first-letter p:first-letter 选择每个

    元素的第一个字母 :first-line p:first-line 选择每个

    元素的第一行 :first-child p:first-child 选择器匹配属于任意元素的第一个子元素的

    元素 :before p:before 在每个

    元素之前插入内容 :after p:after 在每个

    元素之后插入内容 :lang(language) p:lang(it) 为

    元素的lang属性选择一个开始值

伪元素

  • :first-line
  • :first-letter
  • :before
  • :after
  • :first-child
  • :lang(language)
  • :link a:link 选择所有未访问链接
  • :visited a:visited 选择所有访问过的链接
  • :active a:active 选择正在活动链接
  • :hover a:hover 把鼠标放在链接上的状态
  • :focus input:focus 选择元素输入后具有焦点

媒体类型@media

  • all
  • aural
  • braille
  • embossed
  • handheld
  • print
  • projection
  • screen
  • tty
  • tv

属性选择器

  • [attribute]
  • [attribute=“value”]
  • [attribute~=“value”] 之一
  • [attribute|=“value”] 指定值开头后面跟-也行
  • [attribute^=“value”] 指定值开头
  • [attribute$=“value”] 指定结尾
  • [attribute*=“value”] 包含

计数器

  • counter-reset 创建或重置计数器
  • counter-increment 递增变量
  • content 插入内容
  • counter()

!important