如何用CSS定义表格与模拟表格

html-css014

如何用CSS定义表格与模拟表格,第1张

用div模拟表格而已:

<body> 

<dividdivid="wrapper"> 

<dividdivid="header"></div> 

<dividdivid="main"> 

<dividdivid="nav"> 

?navigationcolumncontent…  

</div> 

<dividdivid="extras"> 

?newsheadlinescolumncontent…  

</div> 

<dividdivid="content"> 

?mainarticlecontent…  

</div> 

</div> 

</div> 

</body>

css样式

#main{  

display:table  

border-collapse:collapse  

}  

 

#nav{  

display:table-cell  

width:180px  

background-color:#e7dbcd  

}  

 

#extras{  

display:table-cell  

width:180px  

padding-left:10px  

border-right:1pxdotted#d7ad7b  

}  

 

#content{  

display:table-cell  

width:380px  

padding-left:10px  

}

CSS代码:

font-size:

15px

width:

70%

margin:auto

text-align:center

font-size:

15px

border-width:

1

border:1px

solid

#cccccc

注解:border

只定义外围边框,所以table要定义边框,包括内部边框要分别定义

table

td的border试下

table

{border:1px

border-collapse:collapse

}td{

border:1px}

<title>Document</title>

<style>

table tr td:nth-child(1){color:red}

</style>

</head>

<body>

<!-- 用css3选择器 -->

<table>

<tr>

<td>11111111</td>

<td>2222222222</td>

</tr>

</table>