Created
September 26, 2012 03:12
-
-
Save tessalt/3785780 to your computer and use it in GitHub Desktop.
#selects
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
<select> | |
<option>My Assets</option> | |
<option>All Assets</option> | |
<option>Other Things</option> | |
<option>Another really long option</option> | |
</select> |
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
$("select").wrap('<div class="box"/>'); | |
$("select").after("<span class='selecttext'></span>"); | |
var val = $("select option:selected").text(); | |
$(".selecttext").text(val); | |
$("select").change(function(){ | |
var val = $("select option:selected").text(); | |
$(".selecttext").text(val); | |
}); |
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
body { | |
font-family: Arial, sans-serif; | |
font-size: 14px; | |
margin: 20px; | |
} | |
.box { | |
position: relative; | |
background: #e6e6e6; | |
background-image: -moz-linear-gradient(top, white, #e6e6e6); | |
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, white), color-stop(1, #e6e6e6)); | |
background-image: linear-gradient(top, white, #e6e6e6); | |
border: 1px solid #aeaeae; | |
display: inline-block; | |
*display: inline; | |
zoom: 0; | |
border-radius: 5px; | |
box-shadow: 0 1px 1px #d2d2d2; | |
} | |
select { | |
z-index: 10; | |
position: relative; | |
opacity: 0; | |
border: none; | |
-webkit-appearance: none; | |
background: none; | |
outline: none; | |
padding: 4px 12px; | |
} | |
.selecttext { | |
display: inline-block; | |
*display: inline; | |
zoom: 1; | |
background: transparent; | |
position: absolute; | |
left: 5px; | |
z-index: 9; | |
color: #666; | |
padding-top: 4px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment