html - 如何在 HTML 中使表中的 <tr> 透明?

标签 html css

我有一个有背景颜色的表格。但我试图使该表中的 TR 保持透明。我尝试使用 background-color:transparent 没有用。我使用了 !important。仍然没有工作。任何人都可以建议我哪里出错了。

下面是我的代码。

<table style="background: #EAE9E6 100%; width:30%;">
  <tr style="background: transparent !important;">
    <td>
    </td>
    <td>
      <b>Yes</b>
      <b>No</b>
      <b>All</b>
    </td>
  </tr>
  <tr>
    <td>
      <input type="radio" checked="checked" name="Frog" value="0" />
      <input type="radio" name="Cat" value="0" />
      <input type="radio" name="Goat" value="0" />

    </td>
  </tr>
</table>

最佳答案

您不能“覆盖”应用于父元素的背景以“切穿”它。

您需要为所有不是第一行的行应用背景。

table tr:not(:first-child) {
  background: red;
}
<table style="width:30%;">
  <tr>
    <td>
      <b>Yes</b>
      <b>No</b>
      <b>All</b>
    </td>
  </tr>
  <tr>
    <td>
      <input type="radio" checked="checked" name="Frog" value="0" />
      <input type="radio" name="Cat" value="0" />
      <input type="radio" name="Goat" value="0" />

    </td>
  </tr>
  <tr>
    <td>
      <input type="radio" checked="checked" name="Frog" value="0" />
      <input type="radio" name="Cat" value="0" />
      <input type="radio" name="Goat" value="0" />

    </td>
  </tr>
</table>

关于html - 如何在 HTML 中使表中的 <tr> 透明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40109702/

相关文章:

javascript - 通过从 html 对象 ID(例如按钮 ID)传递变量来合并 javascript 函数

html - 如何在表格标题下放置水平线?

html - 具有两个动态列和三个元素的 CSS Flexbox 布局

jquery - REM 作为大众响应式 CSS 站点

html - 灰度 - 如何自动禁用它

html - 缓存静态 HTML 站点

javascript - iframe 元素本身返回 null?

css - 位置固定的元素

html - Windows Phone Internet Explorer 在一个 td 中放大文本

javascript - 如何删除使用 jquery 添加的样式属性