【问题标题】:How to align right parts of the text in select option list?如何在选择选项列表中对齐文本的右侧部分?
【发布时间】:2018-05-29 09:33:53
【问题描述】:

如何在选择选项列表中对齐文本的右侧部分

<option>Income1       250</option>
<option>Income2       100</option>
<option>Income3       150</option>

【问题讨论】:

  • 你想做什么?你的代码在哪里...?
  • 当我在 html 中打开下拉列表时,我希望看到收入文本左对齐和数字右对齐。

标签: html select dropdown option


【解决方案1】:

恐怕您无法做到这一点,也许如果您使用向右对齐的占位符,而实际选项向左对齐...

但是,如果您不介意在下拉列表的一行中有两个不同的选项,您可以使用这个 jQuery 插件(加上普通的 jQuery 库)。

https://github.com/shawnchin/jquery-gentleSelect

并像这样使用它

$(document).ready(function() {
    $('#selector').gentleSelect(({
        rows: 2,
        itemWidth: 50,
    });
});

【讨论】:

    【解决方案2】:

    您可以为每个元素添加一个类...例如

    选项 class="name1"

    然后在 css 文件中使用 .name1 调用它。完成此操作后,您可以使用“浮动”并选择您希望它坐的位置......左右或居中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      • 2019-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多