标签:
一,基本语法
//1,css引入方法
<link rel="stylesheet" type="text/css" href="styles.css">
2,css书写格式
h1,h2{
color:blue;font_size
}
二,派生选择器:
根据元素其位置关系定义上下文样式。
例如:我们只想li中的strong中使其样式改为红色,而p的strong不变。
<p><strong>p strong</strong></p> <ul> <li><strong>li strong</strong></li> </ul>
li strong{
color:red;
}
三,id基础选择器
1,id选择器可以标有id的html页面进行标识。用#来定义。
<p id="id1">id testttttt</p>
#id1{
color:pink;
}
2,id选择器和派生选择器一起使用
<p id="id1">id testttttt<a href="aasdfasf">www.baidu.com</a></p>
#id a{
color:blue;
}
四,类选择器;
以一个点来显示。他也可以作为派生选择器
<p class="pclass">这是class标签啊</p>
//css
.pclass{
color:red;
}
他也可以做派生选择器使用。
五,属性选择器:
对带有指定样式的html元素设置样式。
<p title="f">shuxingxuanzeqiadafsadf</p>
//css
<style type="text/css">
[title]{
color:red;
}
</style>
属性和值选择器。
<p title="f">shuxingxuanzeqiadafsadf</p>
<p title="kk">shuxingxuanzeqiadafsadf</p>
//css
<style type="text/css">
[title]{
color:red;
}
[title="kk"]{
color:blue;
}
</style>
标签:
原文地址:http://my.oschina.net/u/2480757/blog/519737