Created
March 22, 2013 10:51
-
-
Save marciobarrios/5220454 to your computer and use it in GitHub Desktop.
Styling selects for IE8+
This file contains hidden or 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
/** | |
* Styling selects for IE8+ | |
*/ | |
body { text-align: center; padding: 2em; } | |
* { font: 14px/20px sans-serif; margin: 0; padding: 0; } | |
.selectfield { position: relative; display: inline-block; } | |
.selectfield select { | |
width: 100%; | |
display: inline-block; | |
white-space: nowrap; | |
border: 1px solid rgb(224, 224, 224); | |
border-top-color: rgb(203, 203, 203); | |
padding: 9px 30px 7px 9px; | |
background: rgb(255, 255, 255); | |
appearance: none; | |
-moz-padding-end: 8px; /* hack :( */ | |
box-shadow: inset 0 10px 10px -10px rgba(0, 0, 0, 0.1); | |
border-radius: 4px; | |
transition: box-shadow .3s ease, border-color .2s ease; | |
} | |
/* Sorry! Hack for IE8/9 selects */ | |
@media screen\0 { | |
.selectfield select { padding-right: 6px; margin: 0; /*z-index: 3; position: relative;*/ } | |
} | |
.selectfield select:focus { | |
outline: 0; | |
border-color: rgb(61, 173, 217); | |
box-shadow: inset 0 10px 10px -10px rgba(0, 0, 0, 0.1), 0 0 6px 0 rgba(61, 173, 217, 0.6); | |
} | |
.selectfield:after, | |
.selectfield:before { | |
content: ""; | |
position: absolute; | |
display: block; | |
pointer-events: none; | |
} | |
.selectfield:after { /* arrow */ | |
width: 0; height: 0; | |
top: 50%; right: 9px; | |
margin-top: -1px; | |
border: 4px solid transparent; border-top-color: rgb(102, 102, 102); | |
} | |
.selectfield:before { /* arrow container */ | |
width: 24px; | |
top: 1px; right: 1px; bottom: 1px; | |
border-left: 1px solid rgb(226, 226, 226); | |
box-shadow: inset 0 1px rgba(255, 255, 255, .75); | |
border-radius: 0 4px 4px 0; | |
background: rgb(255, 255, 255); | |
background: linear-gradient(rgb(245, 245, 245), rgb(242, 242, 242)); | |
} |
This file contains hidden or 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="selectfield"> | |
<select> | |
<option>Option 1</option> | |
<option>Option 2</option> | |
<option>Option 3</option> | |
</select> | |
</div> |
This file contains hidden or 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
// alert('Hello world!'); |
This file contains hidden or 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
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment