效果预览:

代码:

 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>html 简单的table样式</title>
<style type="text/css">
/* gridtable */
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #dedede;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #ffffff;
}
/* /gridtable */ /* imagetable */
table.imagetable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #999999;
border-collapse: collapse;
}
table.imagetable th {
background:#b5cfd2 url('cell-blue.jpg');
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #999999;
}
table.imagetable td {
background:#dcddc0 url('cell-grey.jpg');
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #999999;
}
/* /imagetable */
/* altrowstable */ table.altrowstable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #a9c6c9;
border-collapse: collapse;
}
table.altrowstable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
table.altrowstable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
.oddrowcolor{
background-color:#d4e3e5;
}
.evenrowcolor{
background-color:#c3dde0;
}
/* /altrowstable */ /* hovertable */
table.hovertable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #999999;
border-collapse: collapse;
}
table.hovertable th {
background-color:#c3dde0;
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
table.hovertable tr {
background-color:#d4e3e5;
}
table.hovertable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
/* /hovertable */ </style>
</head>
<body> <h2>table样式1:单像素边框CSS表格</h2>
<table class="gridtable">
<tr>
<th>Info Header 1</th>
<th>Info Header 2</th>
<th>Info Header 3</th>
</tr>
<tr>
<td>Text 1A</td><td>Text 1B</td><td>Text 1C</td>
</tr>
<tr>
<td>Text 2A</td><td>Text 2B</td><td>Text 2C</td>
</tr>
</table> <h2>table样式2:带背景图的CSS样式表格</h2>
<table class="imagetable">
<tr>
<th>Info Header 1</th>
<th>Info Header 2</th>
<th>Info Header 3</th>
</tr>
<tr>
<td>Text 1A</td><td>Text 1B</td><td>Text 1C</td>
</tr>
<tr>
<td>Text 2A</td><td>Text 2B</td><td>Text 2C</td>
</tr>
</table> <h2>table样式3:自动换整行颜色的CSS样式表格(需要用到JS)</h2>
<table class="altrowstable" id="alternatecolor">
<tr>
<th>Info Header 1</th><th>Info Header 2</th><th>Info Header 3</th>
</tr>
<tr>
<td>Text 1A</td><td>Text 1B</td><td>Text 1C</td>
</tr>
<tr>
<td>Text 2A</td><td>Text 2B</td><td>Text 2C</td>
</tr>
</tr>
<tr>
<td>Text 3A</td><td>Text 3B</td><td>Text 3C</td>
</tr>
<tr>
<td>Text 4A</td><td>Text 4B</td><td>Text 4C</td>
</tr>
<tr>
<td>Text 5A</td><td>Text 5B</td><td>Text 5C</td>
</tr>
</table> <h2>table样式4:鼠标悬停高亮的CSS样式表格 (需要JS)</h2>
<table class="hovertable">
<tr>
<th>Info Header 1</th><th>Info Header 2</th><th>Info Header 3</th>
</tr>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
<td>Item 1A</td><td>Item 1B</td><td>Item 1C</td>
</tr>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
<td>Item 2A</td><td>Item 2B</td><td>Item 2C</td>
</tr>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
<td>Item 3A</td><td>Item 3B</td><td>Item 3C</td>
</tr>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
<td>Item 4A</td><td>Item 4B</td><td>Item 4C</td>
</tr>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
<td>Item 5A</td><td>Item 5B</td><td>Item 5C</td>
</tr>
</table> <script type="text/javascript">
function altRows(id){
if(document.getElementsByTagName){ var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr"); for(i = 0; i < rows.length; i++){
if(i % 2 == 0){
rows[i].className = "evenrowcolor";
}else{
rows[i].className = "oddrowcolor";
}
}
}
} window.onload=function(){
altRows('alternatecolor');
}
</script>
</body>
</html>

素材图片:

cell-blue.jpg

cell-greyjpg

html 简单的table样式的更多相关文章

  1. 一个简单的TabItem样式。

    分享一个以前项目中用到的简单的TabItem样式. 效果图如下: <SolidColorBrush x:Key="TabItemDisabledBackground" Col ...

  2. 小物件之输出简单的table

    如果需要将一个数组输出一个简单的table可以采用以下代码(该数组非空) <?php $thead=array("name"=>"名称"," ...

  3. table完美css样式,table的基本样式,table样式

    table完美css样式,table的基本样式,table样式 >>>>>>>>>>>>>>>>> ...

  4. 经常使用的两个清爽的table样式

    两个我经常使用的table样式: <html> <head> <title></title> <style type="text/css ...

  5. js简单固定table表头及css问题分析。

    <head> <meta name="viewport" content="width=device-width" /> <tit ...

  6. 通用table样式

    <html> <head> <title>通用table样式</title> <style type="text/css"&g ...

  7. Table样式设置

    <table class="listTable"> <tr><th width="40px">序号</th>&l ...

  8. css table样式

    1.table样式首先设置表格边框,属性设置表格的边框是否被合并为一个单一的边框. table{ border-collapse: collapse; border-spacing: 0;} 2.固定 ...

  9. 好看的table样式

    收藏个好看的table样式 <style type="text/css">table.gridtable { font-family: verdana,arial,sa ...

随机推荐

  1. 福大软工 · BETA 版冲刺前准备之拖鞋旅游队

    拖鞋旅游队BETA 版冲刺前准备 前言 队名:拖鞋旅游队 组长博客:https://www.cnblogs.com/Sulumer/p/10083834.html 本次作业:https://edu.c ...

  2. javascript性能优化之避免重复工作

    javascript最重要也最根本的性能优化标准之一是避免工作,避免工作又包括两点,第一,不做不必要的工作,第二,不做重复的已经完成的工作.第一部分可以通过代码重构完成,第二部分不做重复的工作有时候难 ...

  3. python基础举例应用

    将下述两个变量的值交换s1='alex's2='SB's1,s2=s2,s1print(s1,s2) 判断下述结果msg1='alex say my name is alex,my age is 73 ...

  4. TCCSuperPlayerView让Delphi支持app视频播放!

    今天ChinaCock发布了新版,完美支持视频播放!新版本中,发布了新的控件TCCSuperPlayerView,以支持视频播放. 这是一个可视控件,拖放到Form上,调整好大小与位置,就可以调用他的 ...

  5. WHID Injector:将HID攻击带入新境界

    HID Attack是最近几年流行的一类攻击方式.HID是Human Interface Device的缩写,意思是人机接口设备.它是对鼠标.键盘.游戏手柄这一类可以操控电脑设备的统称. 由于电脑对这 ...

  6. ubuntu安装nodejs,npm live-server

    sudo apt-get install curl 先安装的是curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/in ...

  7. mail工具的安装、配置及问题处理

    使用mail发邮件时,应先将相关邮件服务启动,本文主要介绍sendmail邮件工具的配置方法和问题处理. 1.安装 ubuntu中sendmail函数可以很方便的发送邮件,ubuntu sendmai ...

  8. less中使用calc

    css3中可以使用calc()来实现自适应布局 例如:width:“calc(100%  - 25px)” width: calc(expression); ==> expression是一个表 ...

  9. [转]熵(Entropy),交叉熵(Cross-Entropy),KL-松散度(KL Divergence)

    https://www.cnblogs.com/silent-stranger/p/7987708.html 1.介绍: 当我们开发一个分类模型的时候,我们的目标是把输入映射到预测的概率上,当我们训练 ...

  10. Python用re正则化模块在字符串查找特定字符串

    实验需要,在一个含有几亿个字符的txt文件中查找特定的字符串,首先用re模块进行查找 from time import clock import re start=clock() label_file ...