我觉得没必要设置tbody 的这两个样式吧,可以设置table的样式 啊,你看下面的代码:
<html>
<head>
<title>tbody_test</title>
</head>
<style>
table{ border-right:1px solid #009933border-top:1px solid #009933}
table tr td{ border-bottom:1px solid #009933border-left:1px solid #009933padding:4px}
</style>
<body>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>213212</td>
<td>sdfsdf</td>
<td>sdfsdfs</td>
</tr>
<tr>
<td>213212</td>
<td>sdfsdf</td>
<td>sdfsdfs</td>
</tr>
<tr>
<td>213212</td>
<td>sdfsdf</td>
<td>sdfsdfs</td>
</tr>
</tbody>
</table>
</body>
</html>
这样也可以实现边框的效果啊!
您好!以下是最典型的细线表格,具备最基本的设置。供参考:
<!doctype html><html>
<head>
<meta charset="utf-8">
<title>表格CSS设置</title>
<style>
#tb1 {
border-collapse: collapse /* 折叠边框产生细线表格*/
border: 2px solid black /* 外框粗线、内部细线表格,表格线为黑色 */
}
#tb2 {
border-collapse: collapse /* 折叠边框产生细线表格*/
border: 1px solid red /* 细线表格,表格线为红色 */
}
</style>
</head>
<body>
<br>
<table id="tb1" width="379" height="87" border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="123" height="34">&nbsp</td>
<td width="122">&nbsp</td>
<td width="126">&nbsp</td>
</tr>
<tr>
<td height="25">&nbsp</td>
<td>&nbsp</td>
<td>&nbsp</td>
</tr>
<tr>
<td>&nbsp</td>
<td>&nbsp</td>
<td>&nbsp</td>
</tr>
</tbody>
</table>
<br>
<table id="tb2" width="379" height="89" border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="123" height="36">&nbsp</td>
<td width="122">&nbsp</td>
<td width="126">&nbsp</td>
</tr>
<tr>
<td height="25">&nbsp</td>
<td>&nbsp</td>
<td>&nbsp</td>
</tr>
<tr>
<td>&nbsp</td>
<td>&nbsp</td>
<td>&nbsp</td>
</tr>
</tbody>
</table>
</body>
</html>
显示结果:
内嵌标签: thead (可选)、 tbody (可选)、td、tr、colgroup 、 caption (可选)
属性:align ,bgcolor ,bordercolor,border ,cellpadding ,cellspacing ,frame ,width ,summary ,rules 。
现在的table的属性基本已经过时,都使用css进行设置table样式。
1.border-collapsecollapse | separate
collapse : border线合并
separate: border线分隔,默认属性
ps: 使用collapse 此属性时, border-spacing 、empty-cells和 border-radius 失效 ,无任何效果。
2.border-spacinghorizontal <length >| vertical <length >
3.vertical-align 设置内容与图片位置
4.table-layout auto | fixed
ps: auto 表格布局自适应宽度
fixed 表格布局固定宽度,文字内容等可能会溢出
5.caption-side 针对于caption标签的css样式设置
6.empty-cells 但单元格内无内容时候,可设置隐藏
参考:
https://www.sitepoint.com/community/t/table-format-using-css-border-issue/36882/3
https://css-tricks.com/almanac/properties/b/border-collapse/
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Table