How to change the font size of select options?

Asked

Viewed 2,509 times

0

I have a select in my form but I can’t change the font size of the options.

See image below:

inserir a descrição da imagem aqui

How to increase the font size of the list of options? Because I’ve tried font-size and nothing worked.

HTML

<figure class="cx-fotos-portugal">

    <form>
    <select>
        <option selected="selected">Escolha a cidade</option>
        <option value="">Cascais</option>
        <option value="">Lisboa</option>
        <option value="">Porto</option>
    </select>
    </form>

    <img src="./fotos-portugal/foto-portugal-capitania-do-porto-cascais.jpg">

</figure>

CSS

figure.cx-fotos-portugal{
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

figure.cx-fotos-portugal form{
    position: absolute;
    background-image: url("../imagens/ponto-transparente-seletor-principal.png");
    padding: 20px;
    border-radius: 10px;
}

figure.cx-fotos-portugal img{
    width: 100%;
    height: 100%;
    max-height: 550px;
}

figure.cx-fotos-portugal form select{
    font-size: 35px;
    padding: 5px;
    border: 1px solid #b9bdc1; 
    color: #797979; 
    height: 55px;
}

figure.cx-fotos-portugal form select option{
    font-size: 35px;
    padding: 5px;
    border: 1px solid #b9bdc1; 
    color: #797979; 
    height: 55px;
}

1 answer

1

You can add the tag <optgroup>

optgroup { font-size:35px !important; }
 <form>
        <select>
            <optgroup>
            <option selected="selected">Escolha a cidade</option> 
            <option value="">Cascais</option>
            <option value="">Lisboa</option>
            <option value="">Porto</option>
            </optgroup>
        </select>
    </form>



    

  • I edited because, I gave a shot and I covered the selected option as well. No need.

  • Here it did not effect. See! figure.cx-fotos-portugal form select optgroup{&#xA; font-size: 35px;&#xA;}

  • It didn’t work for you either. Click to view the list of options, the names Cascais, Lisboa and port are with smaller font.

  • Gladison, it did work. Give a look. https://jsfiddle.net/k2w1rzxs/

  • 1

    Is there any .css done by you or imported by you that does not allow you to work right. For experiment purposes add the ! Right in front of the style I demonstrated.

  • 1

    I provided the executable here and also a jsfiddle. In all cases the option changes in size.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.