HTML表格对齐权 [英] Html Table alignment right

查看:90
本文介绍了HTML表格对齐权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

--------------------------------
| item a                 item b |
| item c         item d  item e |

---------------------------------
| item a         item b          |
| item c         item d  item e  |

我在一个表中有两行,我希望它们每行都有一个左对齐的项目,以及一些右对齐的项目,例如上面的第一个示例。

I have two rows in a table, and I'd like them to each have a left aligned item, and some right aligned items, like in the first example above.

但是,当我设置 item b 时, item d item e align = right ,我得到了上面第二个示例的行为。为什么项目b 项目d 对齐而不是正确

However, when I set item b, item d, and item e to align="right", I get the behavior of the second example above. Why is item b lining up with item d and not right?

修改 Jsfiddle

推荐答案

您的语法有些错误。当我相信您的意思是 style = text-align:right; 时,您正在使用 style = align-right >。您还需要在< td> 中添加 colspan = 2 ,这需要跨越两列- aka项目b单元格:

You had some incorrect syntax. You were using style="align-right" when I believe you meant style="text-align:right;". You also need to add a colspan="2" to the <td> which needs to span 2 columns - aka the "item b" cell:

<table width="500px">
    <tr>
        <td>
            item a
        </td>
        <td style="text-align:right;" colspan="2">
            item b
        </td>
    </tr>
    <tr>
        <td>
            item c
        </td>
        <td style="text-align:right;">
            item d
        </td>
        <td style="text-align:right;">
            item e
        </td>
    </tr>
</table>

http://jsfiddle.net/A5LDZ/2/

这篇关于HTML表格对齐权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆