代码之家  ›  专栏  ›  技术社区  ›  Jamal Abdul Nasir

选择标签的选项右对齐

  •  6
  • Jamal Abdul Nasir  · 技术社区  · 14 年前

    那么,如何显示与select元素右下角对齐的选项呢?

    当心。。。

    5 回复  |  直到 11 年前
        1
  •  6
  •   Richard JP Le Guen    14 年前

    While the other answers are correct, and you can use the style attribute, you'd be better off using an external CSS file.

    In your HTML document, add a <link> to your CSS file in the <head> of the document:

    <head>
        <title>Example</title>
        <link type="text/css" rel="stylesheet" href="path/to/the/file.css" />
    </head>
    

    给你 <select> (或 <option> 元素A class 属性。

    <select class="JamalAbdulNasir">
        <option class="Jamal">Jamal</option>
        <option class="Abdul">Abdul</option>
        <option class="Nasir">Nasir</option>
    </select>
    

    在样式表中包含一个以 <选择& 通过标签 属性。

    select.JamalAbdulNasir {
        text-align:right;
    }
    

    …或 <选项& GT; 要右对齐的标记。

    input.Abdul {
        text-align:right;
    }
    
        2
  •  6
  •   Anonymous user3428448    11 年前

    你可以使用 direction: ltr; direction: rtl; 用于文本对齐方向

        3
  •  0
  •   GOsha    14 年前

    如果我理解你的问题:

    <select style="text-align:right;">
    <option >asd</option>
    <option>asdasd</option>
    <option>asdasd</option>
    <option>asdasd</option>
    </select>
    
        4
  •  0
  •   vertazzar    14 年前
    <option value="1" style="text-align: right;">
    test?</option>
    
        5
  •  0
  •   user2561852    11 年前

    我知道这很晚,但我知道如何将选择框向左或向右,我不知道如何将其向上或向下,但希望这将回答人们寻找答案的问题,而不一定是操作的问题。

    <select style="float:right;">
    <option >asd</option>
    <option>asdasd</option>
    <option>asdasd</option>
    <option>asdasd</option>
    </select>
    

    显然,可以将其更改为style=“float:left;”,使其向左对齐。