繼承:子元素繼承父元素屬性
例如:
<body>
<p></p>
</body>
body標簽設置的屬性p標簽會繼承
全局通用屬性建議設置在祖元素中,以便子元素繼承復用。
例如:
<body>
<header>
<div><div>
</header>
<main></main>
<footer></footer>
</body>
通用樣式建議寫在body中,字體、字體大小、文字顏色等
body{
font-family:Arial,Helvetica;
}
!并不是所有樣式都可以繼承。
不被繼承情況:
1、元素位置(position)屬性、外邊距(margin)、內邊距(padding)、邊框(border)、背景(background)、大?。╳idth、height)等等。
2、標簽自帶樣式。
例如:<a>標簽字體顏色藍色
新聞熱點
疑難解答