Right Align Table?
This code:
<table border="1">
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
</tr>
</table>
http://jsfiddle.net/ca86D/ Generates:
a | b | c | d
How can I make it generate 开发者_开发技巧:
d | c | b | a
?
Without changing the order of the < th >
You can add dir="rtl"
attribute to table:
<table border="1" dir="rtl">
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
</tr>
</table>
Demo: http://jsfiddle.net/74XHk/1/
(tried to add it to tr
, that didn't work)
add in your css th {float:right}
. This will reverse the sequence, because will start with first th
which contains d
and will float it at right, then the second and so on.
Demo: http://jsfiddle.net/ca86D/2/
Surely just
<table border="1">
<tr>
<th>d</th>
<th>c</th>
<th>b</th>
<th>a</th>
</tr>
</table>
Hope I didn't misunderstand your question.
<table border="1">
<tr>
<th>d</th>
<th>c</th>
<th>b</th>
<th>a</th>
</tr>
</table>
精彩评论