css和js處理隔行換色的問題

來源:互聯網
上載者:User

標籤:沒有   1.0   viewport   自己   doc   document   function   clear   char   

  
  1. <html>  
  2.     <head>  
  3.         <meta charset="utf-8">  
  4.         <meta name="" content="content">  
  5.         <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>  
  6.         <title></title>  
  7.         <link rel="stylesheet" type="text/css" href="">  
  8.         <script src="js/jquery1.8.3.min.js"></script>  
  9.     </head>  
  10.     <script>  
  11.         /*$(document).ready(function(){  
  12.             $(‘.product_tit:even‘).css({"color":"#21c178"});  
  13.             $(‘.product_tit:odd‘).css({"color":"#459ee6"});  
  14.         })*/  
  15.     </script>  
  16. <div> <span style="white-space:pre">   </span><style>  
  17.   <span style="white-space:pre">      </span>#list2:nth-of-type(odd) .product_tit{color:#21c178}  
  18.   <span style="white-space:pre">      </span>#list2:nth-of-type(even) .product_tit{color:#459ee6}  
  19. <span style="white-space:pre">  </span></style> </div>   <body>  
  20.         <style type="text/css">   
  21.         .list1:nth-of-type(odd){ color:#ffcc00;}  
  22.         .list1:nth-of-type(even){ color:#00ccff;}  
  23.         </style>   
  24.         <div>   
  25.             <ul>   
  26.                 <li class="list1">111111111111111111111111111</li>   
  27.                 <li class="list1">222222222222222222222222222</li>   
  28.                 <li class="list1">333333333333333333333333333</li>   
  29.                 <li class="list1">444444444444444444444444444</li>   
  30.                 <li class="list1">555555555555555555555555555</li>   
  31.                 <li class="list1">666666666666666666666666666</li>   
  32.             </ul>   
  33.         <hr />   
  34.         <div id="list2">  
  35.             <div class="product_tit">7777777777777777777777777777</div>  
  36.         </div>  
  37.         <div id="list2">  
  38.             <div class="product_tit">8888888888888888888888888888</div>  
  39.         </div>  
  40.         <div id="list2">  
  41.             <div class="product_tit">9999999999999999999999999999</div>  
  42.         </div>  
  43.         <div id="list2">  
  44.             <div class="product_tit">0000000000000000000000000000</div>  
  45.         </div>  
  46.         <div id="list2">  
  47.             <div class="product_tit">7777777777777777777777777777</div>  
  48.         </div>  
  49.         </div>  
  50.     </body>  
  51. </html>  

 

備忘:自己添加jquery

 

錯誤的css:

 

[html] view plain copy 
  1. <style>  
  2.     .product_tit:nth-of-type(odd){color:#21c178}  
  3.     .product_tit:nth-of-type(odd){color:#459ee6}  
  4. </style>  

 

 

錯誤的原因:class=product_tit的每個元素都沒有兄弟節點,nth-of-type並不會起作用 


  

css和js處理隔行換色的問題

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.