html - 无法将多个类分配给表

标签 html css border css-tables

我正在使用多个具有不同属性的表。问题是我所有的表似乎都是从一个类“spectable”中获取它们的属性。特别是边框,我不想要任何其他类的边框。如何正确分配多个表?

HTML

/*I only need a table here to keep it centered in the page, so i want no border*/ 
<table class="bantable">
<tr>
<td align="middle">
<div id="container">     
    <!-- Each image is 350px by 233px -->  
    <div class="photobanner">
        <img class="first" src="/banner/AA.JPG" alt="">
        <a target="_blank" href="P1010011.JPG">
    </div>
</div>
</td>
</tr>
</table>

/*this one i want the border in*/
<table class="spectable">
  <tr>
    <th>Type</th>
    <td>GMC 7000 Dump Truck</td>
  <tr>
    <th>Stock#</th>
    <td>70017</td>
    <th>Condition</th>
    <td>N/A</td>
  </tr>
  <tr>
</table>

CSS

table.bantable  table, td, th, tr
{
  border: none;
}

table.spectable  table, td, th 
{
  border: 3px solid #fdff30;
}

table.spectable th 
{
  background-color: #fdff30;
  color: black;
}

最佳答案

您使用 td, th, 表格选择器的方式是错误的。像下面这样更新您的 CSS。

 table.bantable, table.bantable td, table.bantable th, table.bantable tr
 {
  border: none;
 }

 table.spectable, table.spectable td, table.spectable th 
 {
   border: 3px solid #fdff30;
  }

 table.spectable th 
 {
   background-color: #fdff30;
   color: black;
 }

关于html - 无法将多个类分配给表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24537237/

相关文章:

javascript - 如何将子div高度设置为父高度?

javascript - 调用窗口加载事件 - javascript

php - 在 PHP 中使用 css 类

android - 图像周围不需要的边框?

java - 以编程方式向 TextView 添加边框

jquery - 让文本区域充当输入

javascript - 绝对定位时div消失,父级动态高度

asp.net - 防止 ASP.NET 菜单在相邻内容上扩展

javascript - 具有不透明度和 z-index 的 slider 无法正常工作

css - 更改边框 CSS 的宽度