I have been trying to get rid of the default gradient background in Website. I know if I set the -webkit-appereance:none this would be possible but then I will lose the arrows and other behaviors in the dropdown that I want. Is there anyway of setting the background to white with the -webkit-appearance: menulist ?
This is what I have but the background does not change
.ius select{
-webkit-appearance: menulist;
-moz-appearance: menulist;
appearance: menulist;
height:32px;
border:1px solid #c8c8c8;
width:250px;
background:rgba(255, 255, 255, 0);
background: transparent;
}
From the above list, some property values are deprecated in modern browsers. CSS3 has equivalent appearance property to -webkit-appearance property based on the browser compatibility. Such as -webkit- is replaced by -ms- for Internet Explorer, -moz- for Firefox, -o- for Opera etc.
Try this way: -webkit-appearance: button; -moz-appearance: button; Then, you can use a different image as background and place it: background-image: url(images/select-arrow.
It is also available for Android and iOS. However, as with all other iOS web browsers, the iOS version uses the WebKit layout engine instead of Gecko due to platform requirements.
The CSS -webkit-appearance property enables web authors to change the appearance of HTML elements to resemble native User Interface (UI) controls. The CSS -webkit-appearance property is a proprietary CSS extension that is supported by the WebKit browser engine.
The appearance property is generally used for two things:
It's a pretty weird property.
Since you want to remove the native default background, you need to set appearance to none. This will remove all styling (the gradients and the default arrow icons). This isn't a big deal however, since you can just use css to apply more styling to it.
With the markup:
<select id="menulist">
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select>
And CSS:
#menulist {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
height:20px;
border:1px solid rgb(156,156,156);
width:250px;
text-indent: 8px;
/**
* replace this background url with a proper arrow asset
**/
background: url('http://placehold.it/5x10') no-repeat 95% 50%;
}
The full jsfiddle is available here: http://jsfiddle.net/gwwar/vR53Q/2/
Since this property is only supported on Chrome, Safari and Firefox, I would probably go a different route and either use the native select styling or use a dropdown component that you have full control over.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With