How to style a select dropdown with CSS

I've spent the last few hours trying to style a select dropdown. It's lame, so lame. It's lame because the best and prettier options use JavaScript.

That's great, if you don't care about mobile. One of the cool things about select dropdowns is that in mobile they have a special helper:

ios select dropdown

I've looked to a lot of resource but none can be compared to Bootstrap.

So basically I ripped off their select dropdown styles. It looks great on Google Chrome, Safari and, more or less, on Firefox.

With the styles below you can turn this crap:

Into this cool select dropdown:

HTML

<select name="element" id="element">
	<option value="1">First option</option>
	<option value="2">Second Option</option>
	<option value="3">Third Option</option>
</select>Code language: HTML, XML (xml)

CSS

#element{
	
	-webkit-align-items: center;
	-webkit-appearance: menulist-button;
	-webkit-rtl-ordering: logical;
	-webkit-writing-mode: horizontal-tb;
	background-color: rgb(255, 255, 255);
	border-radius: 0px;
	border: 1px solid rgb(204, 204, 204);
	border-image-outset: 0px;
	border-image-repeat: stretch;
	border-image-slice: 100%;
	border-image-source: none;
	border-image-width: 1;
	box-sizing: border-box;
	color: rgb(85, 85, 85);
	cursor: pointer;
	display: inline-block;
	font-size: 14px;
	font-weight: normal;
	height: 30px;
	letter-spacing: normal;
	line-height: normal;
	margin: 0px 0px 10px 0px;
	padding: 4px 6px;

	text-align: start;
	text-indent: 0px;
	text-shadow: none;
	text-transform: none;
	vertical-align: middle;
	white-space: pre;
	word-spacing: 0px;

	
	width: 220px;
}Code language: CSS (css)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *