table好看的css样式

html-css05

table好看的css样式,第1张

这个还行

<style type="text/css">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

}

</style>

指定的<table>为细边框,把<table>放在<div>中即可。

一、首先新建表格,代码如下:

<table width="500" border="1">  <tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr><tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr><tr>  <td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr</table>。

二、在table里加css样式,代码如下:

<table width="500" border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse">  <tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td </tr><tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr><tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></table>。

三、单元格边距(表格填充)(cellpadding) -- 代表单元格外面的一个距离,用于隔开单元格与单元格空间。单元格间距(表格间距)(cellspacing) -- 代表表格边框与单元格补白的距离,也是单元格补白之间的距离,border-collapse:collapse表示表格的两边框合并为一条即可。

用css可以改变table中的字体颜色,用到的工具,notepad++,示例代码如下:

用css控制table中字体的颜色,代码如下:

<style>

.color{color:#ff0000}

</style>

<table><tr><td class="color">请用css给我着色红色</td></tr></table>

运行效果图:

注意事项:table的td本身就支持颜色简单属性。