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

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

时间:2015-01-28 21:15:50      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

 

 

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

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

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

 

技术分享

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

技术分享table
{
技术分享    table-layout
:fixed;
技术分享    empty-cells
:show; 
技术分享    border-collapse
: collapse;
技术分享    margin
:0 auto;
技术分享
}

技术分享td
{
技术分享    height
:20px;
技术分享
}

技术分享h1,h2,h3
{
技术分享    font-size
:12px;
技术分享    margin
:0;
技术分享    padding
:0;
技术分享
}

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

技术分享table.t1 th 
{
技术分享    background-image
: url(th_bg1.gif);
技术分享    background-repeat
::repeat-x;
技术分享    height
:30px;
技术分享
}

技术分享table.t1 td,table.t1 th
{
技术分享    border
:1px solid #cad9ea;
技术分享    padding
:0 1em 0;
技术分享
}

技术分享table.t1 tr.a1
{
技术分享    background-color
:#f5fafe;
技术分享
}

技术分享
技术分享
技术分享
技术分享table.t2
{
技术分享    border
:1px solid #9db3c5;
技术分享    color
:#666;
技术分享
}

技术分享table.t2 th 
{
技术分享    background-image
: url(th_bg2.gif);
技术分享    background-repeat
::repeat-x;
技术分享    height
:30px;
技术分享    color
:#fff;
技术分享
}

技术分享table.t2 td
{
技术分享    border
:1px dotted #cad9ea;
技术分享    padding
:0 2px 0;
技术分享
}

技术分享table.t2 th
{
技术分享    border
:1px solid #a7d1fd;
技术分享    padding
:0 2px 0;
技术分享
}

技术分享table.t2 tr.a1
{
技术分享    background-color
:#e8f3fd;
技术分享
}

技术分享
技术分享
技术分享
技术分享table.t3
{
技术分享    border
:1px solid #fc58a6;
技术分享    color
:#720337;
技术分享
}

技术分享table.t3 th 
{
技术分享    background-image
: url(th_bg3.gif);
技术分享    background-repeat
::repeat-x;
技术分享    height
:30px;
技术分享    color
:#35031b;
技术分享
}

技术分享table.t3 td
{
技术分享    border
:1px dashed #feb8d9;
技术分享    padding
:0 1.5em 0;
技术分享
}

技术分享table.t3 th
{
技术分享    border
:1px solid #b9f9dc;
技术分享    padding
:0 2px 0;
技术分享
}

技术分享table.t3 tr.a1
{
技术分享    background-color
:#fbd8e8;
技术分享
}

技术分享
技术分享-->
技术分享
</style>
技术分享
<script type="text/javascript">
技术分享    
function ApplyStyle(s){
技术分享        document.getElementById(
"mytab").className=s.innerText;
技术分享    }

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

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

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

标签:

原文地址:http://www.cnblogs.com/bhlsheji/p/4256771.html

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