Created
August 21, 2012 19:18
-
-
Save jpsirois/3418477 to your computer and use it in GitHub Desktop.
Dead Simple CSS Only Custom-Select (fallback to standard <select> for IE7 and below)
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
<!DOCTYPE html> | |
<!--[if lt IE 8]><html class="lt-ie8" lang="en"> <![endif]--> | |
<!--[if gt IE 8]><!--><html lang="en"><!--<![endif]--> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Dead Simple Cross-Browser Custom-Select</title> | |
<style> | |
body { | |
margin: 20px; | |
} | |
#styled-select { | |
width: 240px; | |
height: 34px; | |
overflow: hidden; | |
background: lightblue; | |
border: 1px solid #ccc; | |
} | |
#styled-select select { | |
background: transparent; | |
width: 264px; | |
padding: 5px; | |
font-size: 16px; | |
border: 0; | |
height: 34px; | |
display: inline-block; | |
-webkit-appearance: none; | |
-webkit-border-radius: 0; | |
-moz-border-radius: 0; | |
border-radius: 0; | |
} | |
.lt-ie8 #styled-select { | |
width: auto; | |
height: auto; | |
overflow: auto; | |
background: none; | |
border: 0; | |
} | |
.lt-ie8 #styled-select select { | |
background: auto; | |
width: 240px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="styled-select"> | |
<select> | |
<option>Value 1</option> | |
<option>Value 2</option> | |
<option>Value 3</option> | |
<option>Value 4</option> | |
<option>Value 5</option> | |
</select> | |
</div> | |
</body> | |
</html> |
Thanks, the preview didn't work so I made another http://nevilleweb.sk/testing/custom-select-fallback.html :)
I'm using jQuery selectbox
CSS:
select {visibility: hidden}
HTML, before </head>
:
<noscript><style>select {visibility: visible}</style></noscript>
Thank you so much!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Preview here: http://3418477.run-a-gist.herokuapp.com/