2011-10-15 141 views
2

此代码:右对齐表?

<table border="1"> 
    <tr> 
     <th>a</th> 
     <th>b</th> 
     <th>c</th> 
     <th>d</th> 
    </tr> 
</table> 

http://jsfiddle.net/ca86D/ 生成:

a | b | c | d 

我怎样才能使它产生:

d | c | b | a 

不改变<次的顺序>

回答

4

您可以添加dir="rtl"属性表:

<table border="1" dir="rtl"> 
    <tr> 
     <th>a</th> 
     <th>b</th> 
     <th>c</th> 
     <th>d</th> 
    </tr> 
</table> 

演示:http://jsfiddle.net/74XHk/1/

(试图将其添加到tr,没有工作)

+0

'dir'或'direction:'用于处理双向性phen omenon http://www.w3.org/TR/CSS21/visuren.html#direction – Sotiris

0

当然只是

<table border="1"> 
    <tr>   
     <th>d</th> 
     <th>c</th> 
     <th>b</th> 
     <th>a</th> 
    </tr> 
</table> 

希望我没有误解你的问题。

0
<table border="1"> 
    <tr> 
     <th>d</th> 
     <th>c</th> 
     <th>b</th> 
     <th>a</th> 
    </tr> 
</table> 
4

加入您的css th {float:right}。这将颠倒顺序,因为将从第一个th开始,其中包含d,并将浮动它在右侧,然后第二个,依此类推。

演示:http://jsfiddle.net/ca86D/2/