2012-08-08 78 views
2

我想在正确位置的<tr class="sub-title">中添加一个箭头图像。在td中添加另一个图像?

如何在<tr class="sub-title">中添加另一个td

.sub-title td包含背景图像和文字对齐中心。

.sub-title .arrow-toggle包含箭头图像。

<table style="margin-top:-185px;" border="1"> 
    <tbody> 
    <tr> <td> Item 1 </td> </tr> 
    <tr class="sub-title"> 
     <td colspan="5">Sub-Title Here<span class="arrow-toggle"></span></td> 
    </tr> 
    <tr> <td> Item 2 </td> </tr> 
    <tr> <td> Item 2 </td> </tr> 
</tbody> 
</table> 

CSS

.sub-title .arrow-toggle { 
     background: url(/public/images/toggle-arrow.png) no-repeat; 
     width: 20px; 
     height:20px; 
     float:right; 
    } 



    .sub-title td { 
     background: url(/public/images/subtitle.gif) repeat-x; 
     color:white; 
     padding: 5px; 
     font-weight: bold; 
     border-top:none; 
     border-bottom:1px solid #4799bd; 
    } 
+0

那么你的解决方案有什么问题?应该工作正常。 – kidata 2012-08-08 22:41:14

回答

1

你actualy几乎没有。你只是忘了span是一个内联元素,它不能有浮点,宽度和高度应用于它。只需将display: block添加到您的.arrow-toggle类中即可实现。

+0

'display:block' and'float:right;'? – 2012-08-08 22:36:34

+0

是的,漂浮只能在块级元素上工作! – Pevara 2012-08-08 22:40:33

相关问题