Html 选择标签的 OPTIONS 右对齐

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3118258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:36:38  来源:igfitidea点击:

select tag's OPTIONS aligned right

htmlcss

提问by Jamal Abdul Nasir

i want to align container of the OPTIONS of the select element to the right... the default is showing OPTIONS on the LEFT BOTTOM of the control...

我想将 select 元素的 OPTIONS 的容器向右对齐...默认情况下在控件的左下角显示 OPTIONS...

so how will i show OPTIONS aligned to the RIGHT BOTTOM of the select element?

那么我将如何显示与选择元素的右下角对齐的选项?

take care...

小心...

采纳答案by Richard JP Le Guen

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

虽然其他答案是正确的,并且您可以使用该style属性,但最好使用外部 CSS 文件。

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

在您的 HTML 文档中,在文档<link>的 CSS 文件中添加一个<head>

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

Give your <select>(or the <option>) element a classattribute.

给你的<select>(或<option>)元素一个class属性。

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

In your style sheet include a CSS rule which targets that <select>tag by classattribute.

在您的样式表中包含一个 CSS 规则,该规则<select>class属性定位该标签。

select.JamalAbdulNasir {
    text-align:right;
}

... or the <option>tag you want to be right-aligned.

... 或<option>您想要右对齐的标签。

input.Abdul {
    text-align:right;
}

回答by Aetherynne

You can use direction: ltr;or direction: rtl;for the direction of the text alignment

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

回答by user2561852

I know this is way later, but I know how to get the select box either to the left or right, I'm not sure how to get it up or down, but hopefully this will answer the questions of people searching for an answer, not necessarily for the OP.

我知道这是稍后的方式,但我知道如何将选择框向左或向右放置,我不确定如何将其向上或向下放置,但希望这将回答人们寻找答案的问题,不一定适用于 OP。

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

Obviously, one could change it to style="float:left;", to justify it to the left.

显然,可以将其更改为 style="float:left;",以证明其向左对齐。

回答by GOsha

If I understand your question:

如果我理解你的问题:

<select style="text-align:right;">
<option >asd</option>
<option>asdasd</option>
<option>asdasd</option>
<option>asdasd</option>
</select>

回答by vertazzar

<option value="1" style="text-align: right;">
test?</option>