css设计的具有亲和力的表格

作者:jluvip.com 来源:jluvip.com 时间:2008-03-16 19:28:00 

这样做的好处是:

利用表格来装载数据,不言而喻是最好的,你可以很灵活的为每个单元格定义样式。

下面是具体的做法

首先在photoshop设计一个效果出来,通过对各种颜色,小图标等的常识,做出了一个效果令人满意的效果图来。

css设计的具有亲和力的表格

图:颜色的选择和搭配

下一步呢,裁处下面三个图片来作为标题的背景图片
bg_header.jpg
bullet1.gif
bullet2.gif

数据结构为

<table id="mytable" cellspacing="0" summary="The technical
specifications of the Apple PowerMac G5 series">
<caption>Table 1: Power Mac G5 tech specs </caption>
<tr>
 <th scope="col" abbr="Configurations" class="nobg">Configurations</th>
 <th scope="col" abbr="Dual 1.8GHz">Dual 1.8GHz</th>
 <th scope="col" abbr="Dual 2GHz">Dual 2GHz</th>
 <th scope="col" abbr="Dual 2.5GHz">Dual 2GHz</th>
</tr>
<tr>
 <th scope="row" class="spec">Model</th>
 <td>M9454LL/A</td>
 <td>M9455LL/A</td>
 <td>M9457LL/A</td>
</tr>

可以看到我用了scope 属性来确保这个表格在无视觉效果的浏览器下展示出更好的效果,这个属性定义标题元素包含的标题内容是否为 行 (scope="col") 或 列(scope="row") 。

下面是CSS的内容

对于上面的标题,使用和背景来更好的区分出他们

th {
  font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica,
  sans-serif;
  color: #6D929B;
  border-right: 1px solid #C1DAD7;
  border-bottom: 1px solid #C1DAD7;
  border-top: 1px solid #C1DAD7;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: left;
  padding: 6px 6px 6px 12px;
  background: #CAE8EA url(images/bg_header.jpg) no-repeat;
}

th.nobg {
  border-top: 0;
  border-left: 0;
  border-right: 1px solid #C1DAD7;
  background: none;
}

下面定义左侧的标题样式

 

th.spec {  
  border-left: 1px solid #C1DAD7;
  border-top: 0;
  background: #fff url(images/bullet1.gif) no-repeat;
  font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica,
  sans-serif;
}

th.specalt {
  border-left: 1px solid #C1DAD7;
  border-top: 0;
  background: #f5fafa url(images/bullet2.gif) no-repeat;
  font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica,
  sans-serif;
  color: #B4AA9D;
}

这里的数据来自于MAC的technical specifications of each Power Mac G5|http://www.apple.com/powermac/specs.html

下来定义普通的和重要的数据内容

td {
  border-right: 1px solid #C1DAD7;
  border-bottom: 1px solid #C1DAD7;
  background: #fff;
  padding: 6px 6px 6px 12px;
  color: #6D929B;
}

td.alt {
  background: #F5FAFA;
  color: #B4AA9D;

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

译者的话:这个页面经我测试通过W3C标准严格型验证,而且兼容IE,Firefox,Opera等主流浏览器,对于大量数据,可以利用js实现行两种背景交替显示。

原文:http://veerle.duoh.com/comments.php?id=315_0_2_0_C 

标签:表格,设计,css
0
投稿

猜你喜欢

  • vue3.0 上手体验

    2024-04-30 10:26:49
  • javascript的正则表达式

    2010-07-27 12:29:00
  • 关于MySQL绕过授予information_schema中对象时报ERROR 1044(4200)错误

    2024-01-24 07:49:27
  • 基于Python实现自制拼图小游戏

    2021-12-01 03:25:01
  • python 正则式 概述及常用字符

    2023-01-14 14:50:54
  • CentOS7下安装python3.6.8的教程详解

    2022-02-17 17:27:29
  • Python发送http请求解析返回json的实例

    2022-04-11 03:38:28
  • Python XML RPC服务器端和客户端实例

    2022-07-26 05:41:57
  • Python基于递归算法实现的走迷宫问题

    2023-08-25 03:55:05
  • pycharm全局修改方式

    2021-10-11 12:51:56
  • 关于mysql 的时间类型选择

    2024-01-17 11:44:20
  • oracle跨库查询的方法

    2023-07-18 03:15:35
  • PHP的Laravel框架中使用消息队列queue及异步队列的方法

    2024-05-11 10:08:15
  • 带你了解HDFS的Namenode 高可用机制

    2023-12-08 10:20:45
  • 在cmd命令行里进入和退出Python程序的方法

    2023-07-18 04:21:14
  • python的concat等多种用法详解

    2022-08-14 23:37:18
  • python对Excel的读取的示例代码

    2023-03-27 17:55:06
  • python打包多类型文件的操作方法

    2023-05-22 07:23:31
  • 如何高效地访问记录集?

    2009-11-22 19:25:00
  • 详细分析mysql MDL元数据锁

    2024-01-28 18:29:10
  • asp之家 网络编程 m.aspxhome.com