CSS 4.6 样式-表格
1.表格边框border属性
这里的border是简写属性,即将border-width,border-style,border-color写在一起
例如:table, th, td { border: 1px solid blue; }
注:有先后顺序,但可以省略某个table, th, td { border: 1px blue; }
具体参见CSS手册CSS边框属性
2.边框折叠border-collapse属性
可能的值:
separate( ['sepəreit]分离),默认值,边框分开,有两个边框
collapse( [kə'læps]折叠),边框合并为一个,会忽略border-spacing和empty-cells
3.表格宽度和高度width和height
可能的值:数值(px···)或百分比(%)或auto或继承
例如:table { width:100%;}
th {height:50px:}
注:width(表格宽)与border-width(线宽)不同
4.对齐,水平方向(左右中对齐)text-align,竖直方向(顶底中对齐)vertical-align
可能的值:
text-align:left right center
vertical-align:top bottom center
例如:
td {
text-align:left;
vertical-align:center;
}
5.表格颜色
边框颜色border-color(红)
文本颜色color(白)
背景颜色background-color(绿)
6.内边距(字与边框)padding:15px
7.单元格边框距离border-spacing:5px
8.隐藏表格中空单元格上的边框和背景empty-cells
可能的值:
show:默认,在空单元格周围绘制边框。
hide:不在空单元格周围绘制边框。
9.表格布局table-layout(就是列宽,layout布局排版)
可能的值:
automatic,默认,自动布局,列宽由内容决定。
fixed,固定布局,自己设定
例如1:
table-layout:automatic;
结果:
例如2:
<html>
<head><style type=“text/css”>
table.fixed { table-layout:fixed;}
</style></head>
<body>
<table class=“fixed” width=“100%”>
<tr>
<td width=“20%”>10000000000000000</td>
<td width=“40%”>10000000</td>
<td width=“40%”>100</td>
</tr>
</table>
</body>
</html>
结果: