mic*_*con 21 html css html-table
我想放两个表(在同一页面上),它们应该以不同的方式呈现(即为每个表使用不同的CSS).可能吗?
Jon*_*ton 55
在你的HTML中
<table class="table1">
<tr>
<td>
...
</table>
<table class="table2">
<tr>
<td>
...
</table>
Run Code Online (Sandbox Code Playgroud)
在你的CSS中:
table.table1 {...}
table.table1 tr {...}
table.table1 td {...}
table.table2 {...}
table.table2 tr {...}
table.table2 td {...}
Run Code Online (Sandbox Code Playgroud)
您需要为每个表分配不同的类.
使用点'.'在CSS中创建一个类.运算符并在每个类中编写属性.例如,
.table1 {
//some properties
}
.table2 {
//Some other properties
}
Run Code Online (Sandbox Code Playgroud)
并在您的HTML代码中使用它们.
当然,只需为两个表分配单独的css类.
<table class="style1"></table>
<table class="style2"></table>
Run Code Online (Sandbox Code Playgroud)
的CSS
table.style1 { //your css here}
table.style2 { //your css here}
Run Code Online (Sandbox Code Playgroud)