怎么设置漂亮的表格的样式 css

html-css010

怎么设置漂亮的表格的样式 css,第1张

下面来个例子,你可以复制到你的编辑器里修改测试

<style type="text/css">

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

}

</style>

<!-- Table goes in the document BODY -->

<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>

CSS(层叠样式表)级联样式表是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。

这个还行

<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>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

<title>千声盒子</title>

<style type="text/css">

/*不要使用标签名作为类名*/

/*.table{text-align:centerwidth:100%height:100%border-width:thinborder-style:solidborder-color:#AA9FFFborder-collapse:separate}*/

.tbClass {

text-align:center

width:100%height:100%

/*首先对大表格加上左边 和 底边*/

/*我自作主张加上了底边框,可以删掉去*/

/*听说FF下不支持缩写,请你自己把下面的写法拆分出来*/

border-left:2px #AA9FFF solid/* 左边框 */

border-bottom:2px #AA9FFF solid/*底边框*/

}

.tbClass td {/*单元格的上边和右边*/

border-top:2px #AA9FFF solid

border-right:2px #AA9FFF solid

}

.tbClass td {/*测试用,为了看到效果,你可以把这个删掉去*/

/*width:100pxheight:80px*/

}

/*专门为“盒子那行写的类”*/

.boxCell td { height:101pxpadding:0margin:0}

</style>

</head>

<body>

<table id="Box" name="Box" class="tbClass" cellspacing=0><!--注意! 1:我把类名由table改成tbClass了, 2: cellspacing=0-->

<?php

for($i=1$i<=1000$i++){

if($i%5==0){

echo "<td>$i</td>"

echo "</tr>

<tr class=\"boxCell\">

<td>盒子</td>

<td>盒子</td>

<td>盒子</td>

<td>盒子</td>

<td>盒子</td>

</tr>

"/////注意! 这里使用了一个boxCell的CSS类,不会那么多冗余代码

echo "<tr>"

}else{

echo "<td>$i</td>"

}

}

?>

</table>

</body>

</html>

//////最后说明;

1。如果乱码,或无显示,请注意你php文件的编码格式,或在浏览器下选择GBK32编码

2。这种专业问题,如果到Csdn 里发帖,十分钟之内就有人回答了

3。百度的BUG:回复后再修改,就不能保持代码的缩进了 -_-!即不能tab缩进,要换成4个空格