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属性}
层级选择器:
语法:从外层到里层依次书写,用空格分开
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常用属性及选择器
- css中一些常用选择器的介绍
- CSS常用选择器及优先级
- css常用选择器
- CSS中常用选择器及权重计算
- CSS常用选择器
- WEB前端-CSS-选择器&常用样式/属性
- HTML与CSS基础之常用选择器(一)
- 文章标题CSS常用选择器及与HTML结合方式
- CSS常用选择器
- 三个最常用的CSS,jquery选择器
- CSS常用选择器介绍
- Css中常用的选择器
- h5学习之3(h5的常用选择器和css常见样式)
- 04-CSS常用选择器与属性
- HTML5---H5---CSS常用的选择器
- 07-CSS常用选择器二
- CSS中常用的选择器
- HTML常用标记、CSS三种选择器
- css中的一些常用选择器