当前位置: 首页 > 面试题库 >

选择选项字体大小

毛镜
2023-03-14
问题内容

我已经建立了这个小提琴作为我在做什么的一个例子。

我正在尝试做的事情在Firefox中可以正常工作。打开选择选项时,字体大小为 14px

但是,在Google Chrome浏览器中查看它会选择继承的font-size为 34px

理想情况下,我希望将选择选项设置为字体大小 14px

这可能吗?

如果需要,我愿意在jQuery中进行任何相关的修复。

谢谢

代码如下…

我的 CSS 是:

.styled-select {
    overflow: hidden;
    height: 74px;
    float: left;
    width: 365px;
    margin-right: 10px;
    background: url(http://i50.tinypic.com/9ldb8j.png) no-repeat right center #5c5c5c;
}

.styled-select select {
    font-size: 34px;
    border-radius: 0;
    border: none;
    background: transparent;
    width: 380px;
    overflow: hidden;
    padding-top: 15px;
    height: 70px;
    text-indent: 10px;
    color: #ffffff;
    -webkit-appearance: none;
}

.styled-select option.service-small {
    font-size: 14px;
    padding: 5px;
    background: #5c5c5c;
}

HTML标记

<div class="styled-select">
    <select class="service-area" name="service-area">
        <option selected="selected" class="service-small">Service area?</option>
        <option class="service-small">Volunteering</option>
        <option class="service-small">Partnership &amp; Support</option>
        <option class="service-small">Business Services</option>
    </select>
</div>

问题答案:

一种解决方案是将选项包装在 optgroup中

HTML:

<optgroup>
  <option selected="selected" class="service-small">Service area?</option>
  <option class="service-small">Volunteering</option>
  <option class="service-small">Partnership &amp; Support</option>
  <option class="service-small">Business Services</option>
</optgroup>

CSS:

optgroup { font-size:14px; }


 类似资料:
  • 问题内容: 我正在尝试设置选择选项下拉列表的样式。是否可以使选项的字体大小与默认值不同?例如,默认值: 尺寸为7pt;和其中一种选择, 尺寸为13pt。 这是我的下拉列表: 不幸的是,它仅适用于Firefox。可能其他浏览器不支持元素样式吗? 我测试过的浏览器: Chrome:版本27.0.1453.116 m IE:10 的Firefox:22.0 问题答案: 将CSS类添加到标签中以对其进行样

  • 问题内容: 我尝试将插入号向下图标添加到多个选项的第一个选择中,如下图所示: 我无法在上方的小提琴上看到该图标。 以及相应的代码: 问题答案: 您可以简单地将FontAwesome图标添加为所选下拉菜单作为文本。您只需要CSS中的一些东西,FontAwesome CSS和unicode。例如: 单击图标可找到unicode:Fontawesome 更新:从Github问题开始,将multiple属

  • 我希望,如果我选择“mammals”,动物选择选项只显示值为1的选项data-animal_class。 我知道如何获得哺乳动物值,但我不知道如何使用过滤器 这是我的代码:

  • 正在寻找设置下拉列表占位符的字体颜色的方法。当需要select id时,以下操作起作用: 但是,我不希望输入需要这些下拉列表。一旦我移除所需的标记,占位符字体就会变回黑色。 以下是我的下拉列表:

  • 问题内容: 我想设置一个先前选择的要在页面加载时显示的选项。我用以下代码尝试了它: 与 但这是行不通的。有任何想法吗? 问题答案: 这绝对应该工作。确保已将代码放入:

  • 我想调用一个函数时,选择的任何选项。类似于这样: 但不知何故不起作用。有人能帮忙吗。 请注意 我不想捕获更改事件,如果我选择已经选择选项,则不会触发更改事件