开发者

Right Align Table?

开发者 https://www.devze.com 2023-04-13 01:23 出处:网络
This code: <table border=\"1\"> <tr> <th>a</th> <th>b</th> <th>c</th>

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号