html 简单的table样式
效果预览:

代码:
<!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样式的更多相关文章
- 一个简单的TabItem样式。
分享一个以前项目中用到的简单的TabItem样式. 效果图如下: <SolidColorBrush x:Key="TabItemDisabledBackground" Col ...
- 小物件之输出简单的table
如果需要将一个数组输出一个简单的table可以采用以下代码(该数组非空) <?php $thead=array("name"=>"名称"," ...
- table完美css样式,table的基本样式,table样式
table完美css样式,table的基本样式,table样式 >>>>>>>>>>>>>>>>> ...
- 经常使用的两个清爽的table样式
两个我经常使用的table样式: <html> <head> <title></title> <style type="text/css ...
- js简单固定table表头及css问题分析。
<head> <meta name="viewport" content="width=device-width" /> <tit ...
- 通用table样式
<html> <head> <title>通用table样式</title> <style type="text/css"&g ...
- Table样式设置
<table class="listTable"> <tr><th width="40px">序号</th>&l ...
- css table样式
1.table样式首先设置表格边框,属性设置表格的边框是否被合并为一个单一的边框. table{ border-collapse: collapse; border-spacing: 0;} 2.固定 ...
- 好看的table样式
收藏个好看的table样式 <style type="text/css">table.gridtable { font-family: verdana,arial,sa ...
随机推荐
- jmeter中添加压力机
在压测的时候,可能并发比较大,一台机子已经启动不了那么多并发了,这个时候就是有多台机子一起来并发,就要添加压力机 如何添加压力机呢: 1.其他电脑上也安装了jmeter,和其他电脑都能ping通当前电 ...
- Linux平台 获取程序依赖文件
创建sh脚本文件 =========================================================== #!/bin/sh exe=$1 #发布的程序名称des=$2 ...
- linux系统中对SSD硬盘优化的方法
在测试虚拟机往分布式存储中写数据的最大性能时,做的一些系统修改 1.ext4文件系统在SSD硬盘是最快的 2.查看当前系统支持的IO调度算法 dmesg | grep -i scheduler 3.查 ...
- ios初识UITableView及简单用法二(模型数据)
// // ViewController.m // ZQRTableViewTest // // Created by zzqqrr on 17/8/24. // Copyright (c) 2017 ...
- JAVA将异常的堆栈信息转成String
有时候我们需要将系统出现异常的堆栈信息显示到异常页面的一个隐藏的DIV内,这样查看源时就可以快速的定位到异常信息.这个时候就要将异常信息转成String. /* * 将异常的堆栈信息转成String ...
- SQL注入之Sqli-labs系列第二十五关(过滤 OR & AND)和第二十五A关(过滤逻辑运算符注释符)
开始挑战第二十五关(Trick with OR & AND) 第二十五关A(Trick with comments) 0x1先查看源码 (1)这里的or和and采用了i正则匹配,大小写都无法绕 ...
- Readability Assessment for Text Simplification -paper
https://pdfs.semanticscholar.org/e43a/3c3c032cf3c70875c4193f8f8818531857b2.pdf 1.introduction在Brazil ...
- 2017.5.10 MapReduce内部逻辑
MapReduce内部逻辑 Split:HDFS 中的数据以 Split 方式作为 MapReduce 的输入 Block 是 HDFS 术语,Split 是 MapReduce 术语 通常1个 Sp ...
- PostgreSQL的配置文件
PostgreSQL的配置文件主要有如下3个(postgresql.conf,pg_hba.conf,pg_ident.conf)可以通过如下方式查找:postgres=# select name, ...
- javascript json 判断项目 是否存在不存在插入foreach 组合 输出
var a = []; var i; a.push({ key: "key1", value: 23 }); a.push({ key: "key2", val ...