css样式笔记

css样式优先级

!important > 行内样式 > 内部样式 > 外部样式

常用计量单位

  • px
  • %
  • em 子元素字体相对于父元素字体的大小比例
  • rem 子元素字体相对于根元素(html)字体的大小比例

基础选择器优先级

ID > 类>标签

文本样式

  • color 字体颜色
    颜色英文名称、#16进制RGB、rgb/rgba、hsl/hsla
  • text-align 文本对齐方式
    left(默认)、center、right
  • text-decoration 设置字体链接样式
    none、underline、overline、line-through
  • text-transform 控制元素的字母
    none(默认)、capitalize、uppercase、lowercase、inherit
  • text-indent 规定文本中首行缩进
    length、%、inherit
  • letter-spacing 字体间距
    length、normal、inherit
  • line-hight 行高
  • direction 文本方向
    ltr、rtl、inherit
  • word-spacing 字间距(英文单词间距)
    length、normal、inherit
  • white-space 控制元素中空白符的渲染方式
    normal、pre(保留空格)、nowrap(不换行)、pre-wrap、pre-line、inherit
  • text-shadow 设置文本的阴影
    x偏移 y偏移 扩散 color
  • word-break 文本换行方式
    normal、break-all(单词内部换行)、keep-all

字体相关样式

  • font-size 字体大小
  • font-style字体样式
    normal、italic/oblique(斜体)
  • font-weight 字体粗细
  • font-family 设置字体样式