如何理解css呢裤唠?
css是層疊樣式表(Cascading Style Sheet)胁后。
如何使用冰评?
- 行內(nèi)樣式:
<div style="color:red">hello world</div>
- 嵌入樣式:
<style>
*{margin: 0;border: 0;}
body,html{height:100%;}
</style>
- 外聯(lián)樣式
<link rel="stylesheet" href="text.css">
css基礎(chǔ)語(yǔ)法
選擇器{屬性:值阵漏;屬性:值}
p{font-size:15px;color:red;}
css常用選擇器
ID選擇器(#)
類選擇器( . )
標(biāo)簽名選擇器( p{} )
群組選擇器(h1,div,p{})
后代選擇器(div p{})
選擇器的優(yōu)先級(jí)
!important
行內(nèi):1000
ID:100
class,偽類绽左,屬性:10
元素:1
* : 0
css3新增的選擇器
同級(jí)元素通用選擇器:
E ~ F屬性選擇器:
E[att=" val "]
E[att^=" val "]
E[att$=" val "]
E[att*=" val "]與用戶界面相關(guān)的偽類
E:enabled
E:enabled
E:checked
E:selection結(jié)構(gòu)性偽類
E:root
E:nth-child(n)
E:nth-last-child(n)
E:last-child
E:nth-of-type(n)
E:nth-last-of-type(n)
E:first-of-type
E:last-of-type
E:only-child
E:only-of-type
E:empty
E:not(s)
ie的條件測(cè)試
<!--[if lte ie 9]>
<style>
body{
background:deeppink;
}
</style>
<![endif]-->
hack
div{
color: deeppink;
*color: blue; /* ie6 7 */
_color: red; /* ie6 */
}
@media screen and (-webkit-min-device-pixel-ratio:0){ //爭(zhēng)對(duì)chrome
div{
color: lime;
}
}