您的位置:首页 > Web前端 > CSS

css常用选择器

2017-10-19 19:40 369 查看
基本选择器:(优先级:id选择器>class选择器>元素选择器)

1)元素选择器

格式:html标签名{css属性}

例:<style type = "text/css">

span{coloe:red;font-size:100px}

</style>

2)id选择器

例:<div id="div1">hello</div>

<div id="div2">hello</div>

<style type = "text/css">

#div1{background-color:red}

#div2{background-color:yellow}

</style>

3)class选择器

语法:.class的值{css属性}

例:<div class="style1">hello</div>

<div class="style2">hello</div>

<style type = "text/css">

.style1{background-color:red}

.style2{background-color:yellow}

</style>

属性选择器:

语法:元素选择器[属性="属性值"]{css属性}

伪元素选择器:

a标签的伪元素选择器

语法:

静止:a:link{css属性}

悬浮:a:hover{css属性}

触发:a:active{css属性}

完成状态:a:visited{css属性}

层级选择器:

语法:从外层到里层依次书写,用空格分开
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  css