相关资源
搜索
广告是为了发展
你的位置:首页 > 学习 > 代码
 
具有亲和力的表格-隔行换色
 
作者:不详   来源:蓝色理想   编辑:阿志
[字体: ]
 
 

翻译自:A CSS styled table 原文:http://veerle.duoh.com/comments.php?id=315_0_2_0_C 版权归原作者所有这个翻译的页面版权所有,授权蓝色理想。转载请注明出处。

在前一段时间制作了CSS calendar,然后我就想用css制作一个table的模型,该模型遵循亲和力规则,而且有良好的视觉效果.

这样做的好处是: 利用表格来装载数据,不言而喻是最好的,你可以很灵活的为每个单元格定义样式。下面是具体的做法

首先在photoshop设计一个效果出来,通过对各种颜色,小图标等的常识,做出了一个效果令人满意的效果图来。下一步呢,裁出三个主要图片来作为标题的背景图片,如果你对颜色的把握不是很好的话,这里给你提供一些调色工具:

http://www.snook.ca/technical/colour_contrast/colour.html

数据结构为

  1. <table id="mytable" cellspacing="0" summary="The technical
  2. specifications of the Apple PowerMac G5 series">
  3. <caption>Table 1: Power Mac G5 tech specs </caption>
  4. <tr>
  5.   <th scope="col" abbr="Configurations" class="nobg">Configurations</th>
  6.   <th scope="col" abbr="Dual 1.8GHz">Dual 1.8GHz</th>
  7.   <th scope="col" abbr="Dual 2GHz">Dual 2GHz</th>
  8.   <th scope="col" abbr="Dual 2.5GHz">Dual 2GHz</th>
  9. </tr>
  10. <tr>
  11.   <th scope="row" class="spec">Model</th>
  12.   <td>M9454LL/A</td>
  13.   <td>M9455LL/A</td>
  14.   <td>M9457LL/A</td>
  15. </tr>
  16. ...

可以看到我用了scope 属性来确保这个表格在无视觉效果的浏览器下展示出更好的效果,这个属性定义标题元素包含的标题内容是否为 行 (scope=”col”) 或 列(scope=”row”) 。下面是CSS的内容对于上面的标题,使用和背景来更好的区分出他们

  1. th {
  2. font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica,
  3. sans-serif;
  4. color: #6D929B;
  5. border-right: 1px solid #C1DAD7;
  6. border-bottom: 1px solid #C1DAD7;
  7. border-top: 1px solid #C1DAD7;
  8. letter-spacing: 2px;
  9. text-transform: uppercase;
  10. text-align: left;
  11. padding: 6px 6px 6px 12px;
  12. background: #CAE8EA url(images/bg_header.jpg) no-repeat;
  13. }
  14. th.nobg {
  15. border-top: 0;
  16. border-left: 0;
  17. border-right: 1px solid #C1DAD7;
  18. background: none;
  19. }

这里的数据来自于MAC的technical specifications of each Power Mac G5|http://www.apple.com/powermac/specs.html下来定义普通的和重要的数据内容

  1. td {
  2. border-right: 1px solid #C1DAD7;
  3. border-bottom: 1px solid #C1DAD7;
  4. background: #fff;
  5. padding: 6px 6px 6px 12px;
  6. color: #6D929B;
  7. }
  8. td.alt {
  9. background: #F5FAFA;
  10. color: #B4AA9D;
  11. }

至此,整个制作过程结束了。

查看表格效果
查看CSS内容

[从此长大]

 
--------------------------------------------------------------------------www.Cbcz.com
发表评论】【加入收藏】【告诉好友】【关闭窗口