为 <select> 的第一个选项设置样式iOS输入法 [英] Styling the first option of a &lt;select&gt; input on iOS

查看:18
本文介绍了为 <select> 的第一个选项设置样式iOS输入法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 iOS 上设置 select 输入的样式.第一个选项或初始状态应该具有较小的字体大小,但其余选项不应该.

I'm trying to style a select input on iOS. The first option or initial state should have smaller font-size but not the rest of the options.

我有以下 html 结构:

I have the following html structure:

<select class="dropdown">
    <option selected="" value="Navigation">Navigation</option>
    <option value="some-link">Whatever</option>
    <option value="some-link">Another option</option>
    <option value="some-link">Why</option>
    <option value="some-link">What</option>
</select>

我的 CSS 如下所示:

My CSS for it looks like this:

select {
    -webkit-appearance: none;
    font-family: 'Custom-Font', sans-serif;
    font-size:.5em
    line-height:1.8em; // optical center
    background-color: #ccc;
    color: #333;
    border: none;
    padding: 6px 10px 4px 10px;
}

.dropdown {
    background-image: url(img/assets.svg);
    background-position: right 2px;
    background-repeat: no-repeat;
    width: 100%;
    display:block;
    margin-bottom:-1.5em;

    option:not(:first-of-type) {
        font-size:1.5em;
    }
}

发送“验证码”获取 | 15天全站免登陆