16-css继承

58 阅读1分钟

继承

  • css属性继承:子标签能够从父标签身上默认获得的样式

  • 自动继承样式:子元素不需要任何操作,能够直接从父元素身上获取属性作用

    • 字体样式:

      • font-size
      • font-weight
      • font-family
      • font-style
    • 文本样式

      • color
      • text-align
      • text-decoration(按照原理不算自动继承,但是效果和自动继承一致)
      • letter-spacing
      • word-spacing
      • text-transform
      • text-indent
    • 列表样式

      • list-style
    • 鼠标抓手样式

      • cursor: pointer;
  • 手动继承:子元素身上设置相应代码从父元素身上获得对应样式

    css属性名:inherit;
    
    • 注意:继承获得的样式优先级最低