我有一张桌子

<table class="historystyle" >
  <tr>
    <th > name</th>
    <th >location</th>
    <th > job</th>
    <tr>
</table>


name标头中,我不想应用background-image样式,因此我将其放在div元素中并设置style="background-image: none;

但是它不起作用.name标头仍然显示backgorund image。我的代码出了什么问题。.请帮助

<table class="historystyle" >
  <tr>
   <th><div style="background-image: none; ">name</div></th>
    <th>location</th>
    <th> job</th>
    <tr>
</table>


样式

.historystyle th{
  border: 1px solid black;
  background-image: url(../images/bg.gif);
  cursor: pointer;
}

最佳答案

您需要将style="background-image: none"应用于th本身:

<table class="historystyle" >
  <tr>
   <th style="background-image: none">name</th>
    <th>location</th>
    <th> job</th>
    <tr>
</table>


将其应用于div不会影响th的显示方式。默认情况下,(大多数)HTML元素是透明的,因此div没有背景,但是您可以直接看到th,它仍然有背景。

关于jquery - 在表格标题中应用不同的样式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24008647/

10-10 21:57