CSS的三种扩展选择器

来源:互联网 发布:js获取div宽度 编辑:程序博客网 时间:2024/06/04 19:14


[java] view plaincopyprint?
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
  2. <html>  
  3.   <head>  
  4.     <title>extend_select.html</title>  
  5.       
  6.     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">  
  7.     <meta http-equiv="description" content="this is my page">  
  8.     <meta http-equiv="content-type" content="text/html; charset=UTF-8">  
  9.       
  10.     <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->  
  11.   
  12.   </head>  
  13.   <style type="text/css">  
  14.     /*这样会把所有的b标签都改变样式*/  
  15.     /*b{ 
  16.         background-color: yellow; 
  17.     }*/  
  18.       
  19.     /* 
  20.       1,关联选择器    
  21.         这样写,就限定为span标签中的b标签了*/  
  22.     span b{  
  23.         background-color: red;  
  24.     }  
  25.     /* 
  26.       2,组合选择器 
  27.         对多个不同的对象元素进行相同的样式设定  
  28.     */        
  29.     .haha,#div1,p b{  
  30.         background-color: blue;  
  31.     }  
  32.       
  33.     /* 
  34.       3,伪元素选择器 
  35.         其实就是在html中预先定义好的一些选择器,成为伪元素,是因为CSS的术语。 
  36.         格式:     1,标签名:伪元素.类名            2,标签名.类型:伪元素。都可以 
  37.         这四个伪元素不只在a标签上可以,在其他标签上也行!!!!!!!!!!!!!!!! 
  38.         a:link    超链接未点击状态 
  39.         a:visited 被访问后的状态 
  40.         a:hover      光标移到超链接上的状态(未点击) 
  41.         a:active  点击超链接时的状态 
  42.         使用顺序:L--V--H--A 
  43.          
  44.         p:first-line 段落的第一行文本 
  45.         p:first-letter 段落的第一个字母 
  46.          
  47.          
  48.         :focus 具有焦点的元素,IE6浏览器不支持,在FireFox中可以看到效果 
  49.     */  
  50.       
  51.     p:FIRST-LINE{  
  52.         background-color: red;  
  53.     }  
  54.     p:FIRST-LETTER{  
  55.         color: blue;  
  56.         font-size: 30px;  
  57.     }  
  58.       
  59.     input:FOCUS{  
  60.         background-color: grey;  
  61.     }  
  62.       
  63.     a:LINK {  
  64.         background-color: aqua;  
  65.         text-decoration: none;/*该属性用来设置下划线,中划线等等*/  
  66.     }  
  67.     a:VISITED {  
  68.         background-color: red;  
  69.     }  
  70.     a:HOVER {  
  71.         background-color: blue;  
  72.         font-size: 22px;  
  73.     }  
  74.     a:ACTIVE {  
  75.         background-color: fuchsia;  
  76.     }  
  77.   </style>  
  78.   <body>  
  79.   <input type="text"><input type="text"><input type="text">  
  80.   <br/><br/>  
  81.   <p>房价肯定是啦房间<br/>诶我发飞机快的啦 附近的凯萨琳发的</p>  
  82.  <br/><br/><br/><br/><br/>  
  83.         <a href="http://www.baidu.com">a标签----大一些</a>  
  84.     
  85.         <br/><br/><br/><br/><br/>    
  86.      <span class="haha"><b>span</b>-------aaaaaaaaaaaaaaaaaa</span>  
  87.     <span>span-------bbbbbbbbbbbbbbb</span>  
  88.     <hr/>  
  89.     <div id="div1" class="haha"><b>div</b>----cccccccccccccccccccc</div>  
  90.     <div>div----dddddddddddddddddddddd</div>  
  91.     <hr/>  
  92.     <p class="haha">p---------eeeeeeeeeeeeeeeeeee</p>  
  93.     <p>p---------<b>fffff</b>fffffffffffff</p>  
  94.   </body>  
  95. </html>  


转载于:http://blog.csdn.net/wjw_java/article/details/8022899

原创粉丝点击