偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

四種方法輕松實現(xiàn)CSS隔行換色

開發(fā) 前端
你對CSS隔行換色的方法你是否了解,這里和大家分享一下四種實現(xiàn)CSS隔行換色的方法,相信本文介紹一定會讓你有所收獲。

本文和大家重點討論一下四種實現(xiàn)CSS隔行換色的方法,它們分別是background背景圖片,CSSExpression,使用class分別定義,通過JS看實例,希望本文介紹對你有所幫助。

四種實現(xiàn)CSS隔行換色的方法

CSS隔行換色的問題,其實很簡單,您可以根據(jù)您的需要,采用下面的任何一種方法,當然,要適合你的編碼與需求情況:

一、background背景圖片

  如果行高固定的話,推薦使用背景圖,也推薦將行高固定!兼容一切瀏覽器。

二、CSSExpression

  文字:

  1. color:expression(this.sourceIndex%2?'#ff0000':'#000000');  
  2.  

   背景:

  1. background-color:expression(this.sourceIndex%2?'#ff0000':'#000000');  
  2.  

   注意:本方法瀏覽器兼容度不夠,不支持FF3。

三、class分別定義

ExampleSourceCode 

  1. <ul> 
  2. <liclassliclass="bgcolor">...  
  3. <li>...  
  4. <liclassliclass="bgcolor">...  
  5. <li>...  
  6. </ul> 
  7.  

實實在在的寫法。

四、通過JS看實例

SourceCodetoRun

  1. <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <metahttp-equivmetahttp-equiv="Content-Type"content="text/html;charset=utf-8"/> 
  6. <title>www.52CSS.com-四種實現(xiàn)CSS隔行換色的方法</title> 
  7. <linkhreflinkhref="index.css"rel="stylesheet"type="text/css"/> 
  8. <scripttypescripttype="text/javascript"> 
  9. functionbgChange(){  
  10. if(!document.getElementsByTagName)returnfalse;  
  11. vartables=document.getElementsByTagName("table");  
  12. for(vari=0;i<tables.length;i++){  
  13. varodd=false;  
  14. trs=tables[i].getElementsByTagName("tr");  
  15. for(varj=0;j<trs.length;j++){  
  16. if(odd==true){  
  17. trs[j].style.background="#ccc";  
  18. odd=false;  
  19. }else{  
  20. odd=true;  
  21. }  
  22. }  
  23. }  
  24. }  
  25. window.onload=bgChange;  
  26. </script> 
  27. </head> 
  28. <body> 
  29. <tablewidthtablewidth="600"border="0"align="center"cellpadding="0"  
  30. cellspacing="0"> 
  31. <tr> 
  32. <td>測試文字</td> 
  33. <td>測試文字</td> 
  34. <td>測試文字</td> 
  35. </tr> 
  36. </table> 
  37. <scripttypescripttype='text/javascript'> 
  38. //<![CDATA[  
  39. if(document.getElementById('processtime'))document.
  40. getElementById('processtime').innerHTML="<spanclass='runtimedisplay'>  
  41. Runin184ms,9Queries.</span>";  
  42. //]]> 
  43. </script></body> 
  44. </html> 

[可先修改部分代碼再運行查看效果]

【編輯推薦】

  1. 提高CSS文件可維護、可讀性四大技巧
  2. CSS網(wǎng)頁布局中文字排版九大技巧
  3. 解析CSS網(wǎng)頁布局的意義與副作用
  4. 實用但不被IE支持的十大CSS屬性
  5. CSS中id與class命名規(guī)則及編碼最佳習慣
責任編輯:佚名 來源: 52css.com
相關推薦

2010-07-16 13:50:53

Perl哈希表

2020-01-21 19:15:23

漏洞安全IT

2025-03-12 09:54:02

2014-03-17 09:22:43

Linux命令

2022-09-02 14:29:01

JavaScrip數(shù)組屬性

2023-02-03 08:47:20

職位招聘難題

2009-02-25 09:52:14

類型轉(zhuǎn)換.NET 強制轉(zhuǎn)型

2009-03-31 13:12:30

解析XMLJava

2011-06-22 15:21:08

XML

2020-08-10 00:30:55

備份密碼iPhone移動安全

2016-06-28 10:19:31

云計算云安全

2009-11-23 15:57:51

PHP偽靜態(tài)

2021-03-10 10:13:39

爬蟲Python代碼

2021-06-09 10:10:43

數(shù)字化轉(zhuǎn)型IT領導者

2010-08-06 14:28:55

Flex CSS樣式

2009-09-17 16:55:58

C#組件設計

2010-08-02 16:47:46

Flex

2020-07-24 09:56:12

React開發(fā)數(shù)據(jù)

2021-09-03 11:24:04

云計算云計算環(huán)境云應用

2014-02-28 10:50:24

Linux命令
點贊
收藏

51CTO技術(shù)棧公眾號