使用类右对齐文本

  • 本文关键字:文本 右对齐 html
  • 更新时间 :
  • 英文 :


参考此堆栈溢出接受的答案

input {
    text-align:right;
}
<html>
    <head>
        <title>Blah</title>
        <style type="text/css">
        input { text-align:right; }
        </style>
    </head>
    <body>
        <input type="text" value="2">
    </body>
</html>

这种方法将对所有文本框进行右对齐。我如何使用类来区分我想要正确对齐的文本框和不想要的文本框?

<STYLE>
        NumericInput
        {
            text-align:right;
        }
</STYLE>
       <asp:TextBox ID="txtRndRbtAmt" runat="server" CssClass="NumericInput" Enabled="False" Width="100px"></asp:TextBox>

除非我将文本包含在DIV中并将NumericInput类分配给DIV,否则这是不起作用的。

DIV是可以避免的吗?

类选择器以.句点符号开始。

所以应该是:

.NumericInput{
    text-align:right;
}

或者您可以写:

input.NumericInput{
    text-align:right;
}

您使用了错误的选择器。使用

.NumericInput {
  text-align:right;
}

(注意点)

最新更新