I want my options
in hover
state to be yellow but it still blue and border rounding is also not working. Its working for the select
but not for its options
this is my html code
<div class="blackbar" id="blackbar">
<div class="title">
<span id="titleText">Screen</span>
<input class="search" type="text" id="search" placeholder="Search Movie" >
<select class="dropdown" id="fruit">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
<option value="orange">Orange</option>
<option value="grape">Grape</option>
</select>
</div>
</div>
this is my css code for this
#fruit {
margin-left: 150px;
width: 225px;
height: 42px;
border-radius: 12px;
font-size: 24px;
border: none;
font-weight: lighter;
box-shadow: inset 1px 1px 5px rgba(0,0,0, 0.8);
padding-left: 50px; /* Add padding for indentation */
overflow-y: auto; /* Enable vertical scrolling */
max-height: 150px; /* Set maximum height for the dropdown */
}
/* Style the options */
#fruit option {
font-size: 24px;
color: #333;
background-color: #fff;
padding: 10px;
border-radius: 12px;
}
/* Style the hover state */
#fruit option:hover {
background-color: #cef106;
color: #000;
}
help me please
2
Answers
Maybe do
display: none
on the select option and#fruit > option
as your selector?There are multiple responses over here: How to style the option of an HTML select element? . Several of the offered answers work inconsistently, but the accepted answer is:
Basically, currently you can’t use a foolproof method to style existing
option
HTML elements "out of the box", and them work consistently across all browsers without creating a custom select/option solution or using something like bootstrap: https://getbootstrap.com/docs/5.3/examples/dropdowns/.