Created
October 28, 2014 07:51
-
-
Save patrixd/170d8850655bc56e370d to your computer and use it in GitHub Desktop.
Custom native select with CSS3, cross-browser support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="selectContainerWithBtn"> | |
<select> | |
<option value="1">Option 1</option> | |
<option value="2">Option 2</option> | |
<option value="3">Option 3</option> | |
<option value="4">Option 4</option> | |
</select> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* COMBOBOX WITH BTN AND CONTAINER, use native select */ | |
/* Example: $(".selectWithBtn").wrap("<div class='selectContainerWithButton'></div>") */ | |
.selectContainerWithBtn { | |
position: relative; | |
display: inline-block; | |
width: 100%; | |
} | |
.selectContainerWithBtn:before { | |
content: ''; | |
right: 6px; | |
top: 0px; | |
width: 18px; | |
height: 19px; | |
background: #f8f8f8; | |
position: absolute; | |
pointer-events: none; | |
display: block; | |
right: 0; | |
} | |
.selectContainerWithBtn:after { | |
content: ''; | |
font: 11px "Consolas", monospace; | |
color: #aaa; | |
right: 8px; | |
top: 2px; | |
padding: 0 0 2px; | |
border-bottom: 0; | |
position: absolute; | |
pointer-events: none; | |
background: url('http://wf.axesor.es/approot/monitoriza/img/checkanddropArrow.png'); | |
width: 18px; | |
height: 19px; | |
top: 0; | |
right: 0; | |
padding: 0; | |
background-repeat: no-repeat; | |
} | |
.selectContainerWithBtn.btnOnLeft:before { | |
right: auto; | |
left: 0; | |
} | |
.selectContainerWithBtn.btnOnLeft:after { | |
right: auto; | |
left: 0; | |
} | |
.selectContainerWithBtn select { | |
-webkit-appearance: none; | |
-moz-appearance: none; | |
appearance: none; | |
cursor: pointer; | |
border: none; | |
outline: none; | |
display: inline-block; | |
background: #f8f8f8; | |
color: #666; | |
border: none; | |
outline: none; | |
display: inline-block; | |
-webkit-appearance: none; | |
-moz-appearance: none; | |
appearance: none; | |
cursor: pointer; | |
border: 1px solid #ABABAB; | |
padding-top: 2px; | |
padding-left: 2px; | |
font-weight: 100; | |
height: 19px !important; | |
width: 100%; | |
padding-right: 18px; | |
padding-top: 0; | |
} | |
.selectContainerWithBtn select:not([disabled]) { | |
background: white; | |
} | |
.selectContainerWithBtn select.btnOnLeft { | |
direction: rtl; | |
padding-right: 0; | |
padding-left: 18px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment