如何在第一列中将文本左对齐并在其他列中将文本右对齐 [英] How to apply text-align left in the first column and text-align right in the others

查看:66
本文介绍了如何在第一列中将文本左对齐并在其他列中将文本右对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个样式表,如何仅对第一列应用 text-align:left; ,对其他列应用 text-align:right; ?

I have a Table to style, how can I apply text-align:left; just for the first column and text-align:right; for the other columns?

这是我的表格示例:

http://jsfiddle.net/gianlucaguarini/hAv7P/

此刻,所有列的文本对齐方式都保留了.

At the moment the text-align is left for all the columns.

推荐答案

您需要指定以下CSS:

You need to specify the following CSS:

.table td,
.table th
{
    text-align:left;
}

#right,
.table td + td,
.table th + th
{
    text-align:right;
}

此处的示例: http://jsfiddle.net/mWeYM/

您可以在此处了解有关相邻兄弟姐妹CSS选择器的更多信息: http://www.w3.org/TR/CSS2/selector.html#adjacent-selectors

You can read more about adjacent siblings CSS selector here: http://www.w3.org/TR/CSS2/selector.html#adjacent-selectors

这篇关于如何在第一列中将文本左对齐并在其他列中将文本右对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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