I'm trying to make a custom dropdown option list using the <select> tag. I want the selected option to be bigger in font-size than the options in the list.
I added the font-size property to my select menu, but it applies it also to all the options in the list, which makes the list unusable.
HTML
<h1> All houses located at <select id="allhouses__dropdown"> </h1> <option value=""><a>Alle</a></option> <option value=".tilburg" selected><a>Tilburg</h1></a></option> <option value=".amsterdam"><a>Amsterdam</a></option> <option value=".breda"><a>Breda</a></option> <option value=".delft"><a>Delft</a></option> <option value=".den-haag"><a>Den Haag</a></option> <option value=".eindhoven"><a>Eindhoven</a></option> <option value=".enschede"><a>Enschede</a></option> <option value=".groningen"><a>Groningen</a></option> <option value=".leiden"><a>Leiden</a></option> <option value=".maastricht"><a>Maastricht</a></option> <option value=".nijmegen"><a>Nijmegen</a></option> <option value=".utrecht"><a>Utrecht</a></option> <option value=".rotterdam"><a>Rotterdam</a></option> <option value=".wageningen"><a>Wageningen</a></option> <option value=".zwolle"><a>Zwolle</a></option> </select> CSS
#allhouses__dropdown { background: transparent; -webkit-appearance: none; -moz-appearance: none; appearance: none; border: none; outline: none; font-weight: 600; font-size: 2rem !important; color: red; } Is there a way to apply the font-size styling only to the selected option? The solution include jQuery, but only if necessary.
I made a codepen that shows my problem: http://codepen.io/sanderfish/pen/jWpbrv
$primary-color?h1tag is being closed inside your<select>tag.#allhouses__dropdown option:checked { // ... font-size style ... //}does the work.