我想用css上的按钮更改表格行的背景颜色



我使用的是Eclipse,表由用户自动递增,我想用一个按钮圈出5种颜色。我知道改变颜色的新方法是用背景色。哦,桌子是由一个id管理的。

<table class="table table-striped" border="2" >
<thead>
<tr>
<th>id</th>
<th>Cliente</th>
<th>Fecha</th>
<th>Telefono</th>
</tr>
</thead>
<%
while(rs.next())
{
%>

<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
</tr>
<%
}
%>
</table>

我在CSS上的代码是这个

body {
font-family: arial;
background-image:url('Imagen3.jpg');
background-size: cover;
background-attachment: fixed;
}
table {
background-color: white;
text-align: center;
border-collapse: collapse;
width: 500px;

}

如果要更改单元格的颜色您可以在css表{}之后添加

table td{
background-color:yellow;
}

尝试在CSS上使用<tr>...</tr>表行标记。如果你想给一个特定的行上色,那么在标签中使用id或class,然后在CSS文件中使用该id或class。HTML文件:-

<tr id="row1">
<th>id</th>
<th>Cliente</th>
<th>Fecha</th>
<th>Telefono</th>
</tr>
</thead>

CSS文件:-

#row1 {
background-color: yellow;
}

最新更新