码迷,mamicode.com
首页 > Web开发 > 详细

美丽的表格样式(使用CSS样式表控制表格样式)

时间:2014-06-05 20:49:38      阅读:354      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   java   a   

 

 

按照WEB2.0风格,设计了几个表格样式,希望大家喜欢。

WEB2.0提倡使用div开布局,但不是要全然放弃使用表格,表格在数据展现方面还是不错的选择。

如今使用介绍使用CSS样式表来控制、美化表格的方法。

 

bubuko.com,布布扣

bubuko.com,布布扣<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
bubuko.com,布布扣
<html xmlns="http://www.w3.org/1999/xhtml">
bubuko.com,布布扣
<head>
bubuko.com,布布扣
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
bubuko.com,布布扣
<title>精美的表格样式</title>
bubuko.com,布布扣
<style type="text/css">
bubuko.com,布布扣<!--
bubuko.com,布布扣body,table
{
bubuko.com,布布扣    font-size
:12px;
bubuko.com,布布扣
}

bubuko.com,布布扣table
{
bubuko.com,布布扣    table-layout
:fixed;
bubuko.com,布布扣    empty-cells
:show; 
bubuko.com,布布扣    border-collapse
: collapse;
bubuko.com,布布扣    margin
:0 auto;
bubuko.com,布布扣
}

bubuko.com,布布扣td
{
bubuko.com,布布扣    height
:20px;
bubuko.com,布布扣
}

bubuko.com,布布扣h1,h2,h3
{
bubuko.com,布布扣    font-size
:12px;
bubuko.com,布布扣    margin
:0;
bubuko.com,布布扣    padding
:0;
bubuko.com,布布扣
}

bubuko.com,布布扣
bubuko.com,布布扣.title 
{ background: #FFF; border: 1px solid #9DB3C5; padding: 1px; width:90%;margin:20px auto; }
bubuko.com,布布扣    .title h1 
{ line-height: 31px; text-align:center;  background: #2F589C url(th_bg2.gif); background-repeat: repeat-x; background-position: 0 0; color: #FFF; }
bubuko.com,布布扣        .title th, .title td 
{ border: 1px solid #CAD9EA; padding: 5px; }
bubuko.com,布布扣
bubuko.com,布布扣
bubuko.com,布布扣
/*这个是借鉴一个论坛的样式*/
bubuko.com,布布扣table.t1
{
bubuko.com,布布扣    border
:1px solid #cad9ea;
bubuko.com,布布扣    color
:#666;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t1 th 
{
bubuko.com,布布扣    background-image
: url(th_bg1.gif);
bubuko.com,布布扣    background-repeat
::repeat-x;
bubuko.com,布布扣    height
:30px;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t1 td,table.t1 th
{
bubuko.com,布布扣    border
:1px solid #cad9ea;
bubuko.com,布布扣    padding
:0 1em 0;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t1 tr.a1
{
bubuko.com,布布扣    background-color
:#f5fafe;
bubuko.com,布布扣
}

bubuko.com,布布扣
bubuko.com,布布扣
bubuko.com,布布扣
bubuko.com,布布扣table.t2
{
bubuko.com,布布扣    border
:1px solid #9db3c5;
bubuko.com,布布扣    color
:#666;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t2 th 
{
bubuko.com,布布扣    background-image
: url(th_bg2.gif);
bubuko.com,布布扣    background-repeat
::repeat-x;
bubuko.com,布布扣    height
:30px;
bubuko.com,布布扣    color
:#fff;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t2 td
{
bubuko.com,布布扣    border
:1px dotted #cad9ea;
bubuko.com,布布扣    padding
:0 2px 0;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t2 th
{
bubuko.com,布布扣    border
:1px solid #a7d1fd;
bubuko.com,布布扣    padding
:0 2px 0;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t2 tr.a1
{
bubuko.com,布布扣    background-color
:#e8f3fd;
bubuko.com,布布扣
}

bubuko.com,布布扣
bubuko.com,布布扣
bubuko.com,布布扣
bubuko.com,布布扣table.t3
{
bubuko.com,布布扣    border
:1px solid #fc58a6;
bubuko.com,布布扣    color
:#720337;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t3 th 
{
bubuko.com,布布扣    background-image
: url(th_bg3.gif);
bubuko.com,布布扣    background-repeat
::repeat-x;
bubuko.com,布布扣    height
:30px;
bubuko.com,布布扣    color
:#35031b;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t3 td
{
bubuko.com,布布扣    border
:1px dashed #feb8d9;
bubuko.com,布布扣    padding
:0 1.5em 0;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t3 th
{
bubuko.com,布布扣    border
:1px solid #b9f9dc;
bubuko.com,布布扣    padding
:0 2px 0;
bubuko.com,布布扣
}

bubuko.com,布布扣table.t3 tr.a1
{
bubuko.com,布布扣    background-color
:#fbd8e8;
bubuko.com,布布扣
}

bubuko.com,布布扣
bubuko.com,布布扣-->
bubuko.com,布布扣
</style>
bubuko.com,布布扣
<script type="text/javascript">
bubuko.com,布布扣    
function ApplyStyle(s){
bubuko.com,布布扣        document.getElementById(
"mytab").className=s.innerText;
bubuko.com,布布扣    }

bubuko.com,布布扣
</script>
bubuko.com,布布扣
</head>
bubuko.com,布布扣
bubuko.com,布布扣
<body>
bubuko.com,布布扣
<div class="title">
bubuko.com,布布扣    
<h1>大家好,CSS与表格的结合演示样例</h1>
bubuko.com,布布扣    
<table><tr><td>
bubuko.com,布布扣        点击链接切换样式:
<href="javascript:;" onclick="ApplyStyle(this)">t1</a>
bubuko.com,布布扣        
<href="javascript:;" onclick="ApplyStyle(this)">t2</a>
bubuko.com,布布扣        
<href="javascript:;" onclick="ApplyStyle(this)">t3</a>
bubuko.com,布布扣    
</td></tr></table>
bubuko.com,布布扣
</div>
bubuko.com,布布扣
<table width="90%" id="mytab"  border="1" class="t1">
bubuko.com,布布扣  
<thead>
bubuko.com,布布扣    
<th width="10%">网名</th>
bubuko.com,布布扣    
<th width="30%">博客</th>
bubuko.com,布布扣    
<th width="20%">电邮</th>
bubuko.com,布布扣    
<th width="30%">网络硬盘</th>
bubuko.com,布布扣    
<th width="10%">QQ</th>
bubuko.com,布布扣  
</thead>
bubuko.com,布布扣  
<tr class="a1">
bubuko.com,布布扣    
<td>wallimn</td>
bubuko.com,布布扣    
<td>http://blog.csdn.net/wallimn</td>
bubuko.com,布布扣    
<td>wallimn@tom.com</td>
bubuko.com,布布扣    
<td>http://wallimn.ys168.com</td>
bubuko.com,布布扣    
<td>54871876</td>
bubuko.com,布布扣  
</tr>
bubuko.com,布布扣  
<tr>
bubuko.com,布布扣    
<td>长三江</td>
bubuko.com,布布扣    
<td>村在</td>
bubuko.com,布布扣    
<td>北京天安门</td>
bubuko.com,布布扣    
<td>东四十条</td>
bubuko.com,布布扣    
<td>21345678</td>
bubuko.com,布布扣  
</tr>
bubuko.com,布布扣  
<tr class="a1">
bubuko.com,布布扣    
<td>长三江</td>
bubuko.com,布布扣    
<td>村在</td>
bubuko.com,布布扣    
<td>北京天安门</td>
bubuko.com,布布扣    
<td>东四十条</td>
bubuko.com,布布扣    
<td>21345678</td>
bubuko.com,布布扣  
</tr>
bubuko.com,布布扣  
<tr>
bubuko.com,布布扣    
<td>长三江</td>
bubuko.com,布布扣    
<td>村在</td>
bubuko.com,布布扣    
<td>北京天安门</td>
bubuko.com,布布扣    
<td>东四十条</td>
bubuko.com,布布扣    
<td>21345678</td>
bubuko.com,布布扣  
</tr>
bubuko.com,布布扣  
<tr class="a1">
bubuko.com,布布扣    
<td>wallimn</td>
bubuko.com,布布扣    
<td>http://blog.csdn.net/wallimn</td>
bubuko.com,布布扣    
<td>wallimn@tom.com</td>
bubuko.com,布布扣    
<td>http://wallimn.ys168.com</td>
bubuko.com,布布扣    
<td>54871876</td>
bubuko.com,布布扣  
</tr>
bubuko.com,布布扣  
<tr>
bubuko.com,布布扣    
<td>长三江</td>
bubuko.com,布布扣    
<td>村在</td>
bubuko.com,布布扣    
<td>北京天安门</td>
bubuko.com,布布扣    
<td>东四十条</td>
bubuko.com,布布扣    
<td>21345678</td>
bubuko.com,布布扣  
</tr>
bubuko.com,布布扣  
<tr class="a1">
bubuko.com,布布扣    
<td>长三江</td>
bubuko.com,布布扣    
<td>村在</td>
bubuko.com,布布扣    
<td>北京天安门</td>
bubuko.com,布布扣    
<td>东四十条</td>
bubuko.com,布布扣    
<td>21345678</td>
bubuko.com,布布扣  
</tr>
bubuko.com,布布扣  
<tr>
bubuko.com,布布扣    
<td>长三江</td>
bubuko.com,布布扣    
<td>村在</td>
bubuko.com,布布扣    
<td>北京天安门</td>
bubuko.com,布布扣    
<td>东四十条</td>
bubuko.com,布布扣    
<td>21345678</td>
bubuko.com,布布扣  
</tr>
bubuko.com,布布扣
</table>
bubuko.com,布布扣
bubuko.com,布布扣
</body>
bubuko.com,布布扣
</html>
bubuko.com,布布扣

能够到我的网络硬盘下载源代码:http://wallimn.ys168.com

美丽的表格样式(使用CSS样式表控制表格样式),布布扣,bubuko.com

美丽的表格样式(使用CSS样式表控制表格样式)

标签:c   style   class   blog   java   a   

原文地址:http://www.cnblogs.com/zfyouxi/p/3768406.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!