每日一得

          不求多得,只求一得 about java,hibernate,spring,design,database,Ror,ruby,快速開發
          最近關心的內容:SSH,seam,flex,敏捷,TDD
          本站的官方站點是:顛覆軟件

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            220 隨筆 :: 9 文章 :: 421 評論 :: 0 Trackbacks
          key words: css? 隔行換色 控制表格  交替顏色

          最近用到不少css的東西,發現用css是可以省不少麻煩,特別更改效果。

          google了一篇 利用CSS控制表格的交替顏色

          下面是實現的代碼:

          <style?type="text/css">
          <!--
          tr?
          {background-color:expression((this.sectionRowIndex==0)?"":
          (this.sectionRowIndex%2==0)?"red":"blue")
          }
          -->
          </style>
          </HEAD>
          <table>
          <tr>
          <td>第1行</td><td>第1行</td>
          </tr>
          <tr>
          <td>第2行</td><td>第2行</td>
          </tr>
          <tr>
          <td>第3行</td><td>第3行</td>
          </tr>
          <tr>
          <td>第4行</td><td>第4行</td>
          </tr>
          <tr>
          <td>第5行</td><td>第5行</td>
          </tr>
          </table>

          關鍵就是這一句:
          tr?{background-color:expression((this.sectionRowIndex==0)?"":
          (this.sectionRowIndex%2==0)?"red":"blue")}


          對于td的控制如下:
          <style?type="text/css">
          <!--
          tr?
          {background-color:expression((this.sectionRowIndex%2==0)?"red":"blue")}
          td?
          {background-color:expression((this.cellIndex%2==0)?"":((this.parentElement.sectionRowIndex%2==0)?"green":"yellow"))}
          -->
          </style>
          </HEAD>
          <table>
          <tr><td>第1行</td><td>第1行</td><td>第1行<?/td><td>第1行</td><td>第1行</td></tr>
          <tr><td>第2行</td><td>第2行</td><td>第2行<?/td><td>第2行</td><td>第2行</td></tr>
          <tr><td>第3行</td><td>第3行</td><td>第3行<?/td><td>第3行</td><td>第3行</td></tr>
          <tr><td>第4行</td><td>第4行</td><td>第4行<?/td><td>第4行</td><td>第4行</td></tr>
          <tr><td>第5行</td><td>第5行</td><td>第5行<?/td><td>第5行</td><td>第5行</td></tr>
          </table>

          cellIndex 

          另:和數組一樣,第一行從0開始



          但愿對你有用.? :)



          posted on 2006-06-15 18:14 Alex 閱讀(2990) 評論(2)  編輯  收藏 所屬分類: web技術

          評論

          # re: 利用css實現表格的隔行換色 2006-06-15 18:19 晴天娃娃
          哈哈  回復  更多評論
            

          # re: 利用css實現表格的隔行換色 2006-06-15 19:09 Andy luo
          這種css里嵌js的方式在別的瀏覽器里不支持吧。  回復  更多評論
            

          主站蜘蛛池模板: 高清| 泰来县| 谢通门县| 馆陶县| 柯坪县| 远安县| 长乐市| 临城县| 连城县| 英德市| 类乌齐县| 堆龙德庆县| 华安县| 绵竹市| 阳新县| 松桃| 七台河市| 丹东市| 房产| 视频| 洛隆县| 黄陵县| 若尔盖县| 天全县| 仪征市| 卢龙县| 河池市| 临猗县| 和顺县| 宁阳县| 鹿泉市| 漳浦县| 扎囊县| 山西省| 枞阳县| 成武县| 崇阳县| 岐山县| 方正县| 杭州市| 平舆县|