我有一个 table
,其中所有第一列都是右对齐的文本。是否有可能仅在 td
的对齐属性已经为右对齐时将文本对齐到左侧?
为了更好地理解:
HTML:
<table class='tcl'>
<tr>
<td>first column</td>
<td>second column</td>
</tr>
...
</table>
CSS:
.tcl {
border-spacing:0;
border-collapse:collapse;
width:100%;
}
.tcl tr {
height:50px;
}
.tcl td {
width:50%;
text-align:left;
}
.tcl td:first-child {
text-align:right;
/* i would like to align the text of this right aligned column to the left*/
}
编辑:很多人没有真正理解我的意思。text-align 不仅将文本移动到父元素的选定侧面,而且还会改变文本彼此对齐的方式。
所以我想要实现的是这样的效果:
first row
second row
third row
不要这样写
first row
second row
third row
因此,第一列中的文本在两种情况下都向右对齐,但是在第一种情况下,文本的对齐方式是左对齐,在第二种情况下是右对齐。希望这解释清楚了这件事。
text-align: right
? - Mr_Green