【问题标题】:Center aligning text in a select menu [duplicate]在选择菜单中居中对齐文本[重复]
【发布时间】:2019-06-07 18:03:20
【问题描述】:

我的菜单中有一个 ddl,并希望将文本居中。因为 ddl 选择的值是不同的长度,所以它们偏离中心。任何帮助表示赞赏。

我已经尝试了文本缩进,如下例所示。

select {
  font-weight: bold;
  color:#fff;
  background:#444444;
  border:0;
  text-indent: 20%;
  font-size:18px;
  height:29px;
}
<select>
  <option value="0">Mixed Job Lot</option>
  <option value="1">Antiques / Art</option>
  <option value="2">Baby &amp; Toddler Stuff</option>
</select>

【问题讨论】:

  • 不是一个真正的 asp.net 问题。您可以在 snippet 中将其创建为普通的 html/css 以准确说明您的意思

标签: css


【解决方案1】:

只需将text-align-last:center; 添加到您的选择选项中

select {
  font-weight: bold;
  color:#fff;
  background:#444444;
  border:0;
  font-size:18px;
  height:29px;
  text-align-last:center;
}
<select>
  <option value="0">Mixed Job Lot</option>
  <option value="1">Antiques / Art</option>
  <option value="2">Baby &amp; Toddler Stuff</option>
</select>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2015-06-15
  • 1970-01-01
  • 1970-01-01
  • 2021-10-27
  • 1970-01-01
  • 2013-05-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多