分享

用CSS实现网页表格修饰

 昵称10134216 2012-06-12
曾经为添加简单的表格线,困难重重,原来用CSS实现这么简单,现介绍如下(复制到html中即可查看):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www./TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www./1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Grid</title>
<style type="text/css">
body {
font: 0.8em 宋体;
}
table.grid{ /* 折叠所有表格边框--使单元格共享边框*/
  border-collapse:collapse;
}
table.grid td,th { /* 给单元格设置边框线 */
border: 1px solid #99CCCC; 
text-align:left;
        padding:4px 4px;
}
table.grid th[scope="col"] {  /*给列表头文字加粗,加背景色 */
font:bold;
        background-color:#00ddcc;
}
table.grid caption { 
font-size:1.2em;
        margin-bottom: .5em;
}
</style>

</head>
<body><table class="grid">
  <caption>
    <strong>我的书籍</strong>
  </caption>
  <tr>
    <th scope="col"> </th>
    <th scope="col">Stylin'</th>
    <th scope="col">Codin'</th>
    <th scope="col">Stylin'</th>
    <th scope="col">Codin'</th>
  </tr>
  <tr>
    <th scope="row">Languages</th>
    <td>XHTML & CSS</td>
    <td>PHP & SQL</td>
    <td>XHTML & CSS</td>
    <td>PHP & SQL</td>
  </tr>
  <tr>
    <th scope="row">Focus</th>
    <td>Interface design</td>
    <td>Back&#8209;end code</td>
    <td>Interface design</td>
    <td>Back&#8209;end code</td>
  </tr>
<tr>
    <th scope="row">Languages</th>
    <td>XHTML & CSS</td>
    <td>PHP & SQL</td>
    <td>XHTML & CSS</td>
    <td>PHP & SQL</td>
  </tr>
  <tr>
    <th scope="row">Focus</th>
    <td>Interface design</td>
    <td>Back&#8209;end code</td>
    <td>Interface design</td>
    <td>Back&#8209;end code</td>
  </tr>
</table>
</body>
</html>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多