首页 > Web开发 > 详细

CSS3 基本语法

时间:2015-10-21 12:47:33      阅读:381      评论:0      收藏:0      [点我收藏+]

一,基本语法

//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>

 

 

 

 

 

 

 

 

CSS3 基本语法

原文:http://my.oschina.net/u/2480757/blog/519737

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!