无法设置td元素的样式

时间:2011-09-27 18:18:28

标签: html css

我不知道为什么,但我似乎无法在我的脚本中设置td元素的样式。我正在尝试从表格 - 字幕中的所有td元素中删除边框,我想我的css在某种程度上是错误的。

PS:我只能通过内联css删除边框。

HTML:

<table> 
    <thead> 
        <tr>
            <th width="100%" colspan="5">My Recent Activity</th>
        </tr> 
    </thead> 
    <tbody> 
        <tr class="table-subtitles">
          <td style="border: 0"><h4>Date</h4></td>
          <td><h4>Description</h4></td>
          <td><h4>Amount</h4></td>
          <td><h4>Due</h4></td>
          <td><h4>Status</h4></td>
        </tr>
        <?php foreach($this->payments as $payment): ?>
        <tr>
        </tr>
       <?php endforeach; ?>        
        <?php 
            if ((count($this->payments)==0)) :
        ?>      
          <tr>
            <td style="border: 0; text-align: center" colspan="6" class="info">No payments made yet</td>
          </tr>
       <?php endif; ?>    
    </tbody>
</table>

CSS:

#payments-content { width: 480px; float: left; margin-right: 20px; }
#payments-sidebar { width: 270px; float: left; }

.ui-button-large .ui-button-large-text { font-size: 20px; width: 270px; }

// new tables design
.table-subtitles td{ border-bottom: 0 !important; }

5 个答案:

答案 0 :(得分:4)

//不是css评论。你必须使用/ * * /

答案 1 :(得分:1)

您可能会发现希望与border-collapseth结交朋友。

答案 2 :(得分:1)

当我将此表放入测试HTML文件时,默认情况下我没有边框。因此,这可能是您拥有或从CSS导入的某些先前表样式的继承问题。通常情况下,解决这些问题的方法是过度继承我在CSS中制作更具体选择器的任何风格。例如,给你的表一个ID并让你的CSS样式为:

#mytable .table-subtitles td { border-bottom: 0; }

确切了解发生了什么的另一个好方法是在Firefox或Chrome检查器中使用Firebug,确切地查看表行正在拾取,继承或被覆盖的样式。

答案 3 :(得分:0)

你试过border-bottom:0!important

吗?

答案 4 :(得分:-4)

您的问题出在选择器上。

执行.table-subtitles td表示:带有“table-subtitles”类的元素内的TD元素。 你需要的是:

td.table-subtitles { border-bottom:0; }