DVigneault Posted July 20, 2012 Share Posted July 20, 2012 Hey all--I've been using a workaround to style a dropdown list to match the rest of my form. Here's the HTML: <div class="styled-select"> <select> <option>kg</option> <option>lb</option> </select> </div> And the CSS: .styled-select select { background: transparent; font-size: 16px; width: 70px; height: 25px; border: 0px; } .styled-select { border:1px solid #aaa; position: relative; top: 10px; display: inline-block; height:25px; width:50px; box-shadow: 0px 0px 3px #ccc, 0 10px 15px #eee; border-radius:2px; overflow: hidden; background: url(image.jpeg) no-repeat right #eee; } .styled-select select:focus { background: url(image.jpeg) no-repeat right #fff; } Everything is working perfectly except that when I tab to the dropdown list, the background image shifts off to the right by maybe 20px. Any idea how I make it stay put? Thanks! -d Link to comment https://forums.phpfreaks.com/topic/265975-selectfocus-background-image/ Share on other sites More sharing options...
avibitton Posted July 20, 2012 Share Posted July 20, 2012 add in the css(to the right element) background-position-x: XYpx; (XY can be any number) or use precentage like 50%; first try with 50% i think it should center the background in the X-axis. good luck . Link to comment https://forums.phpfreaks.com/topic/265975-selectfocus-background-image/#findComment-1363136 Share on other sites More sharing options...
DVigneault Posted July 21, 2012 Author Share Posted July 21, 2012 Thanks so much for the reply--that looks like it would have worked. I actually gave up a few hours after I posted and just used jQuery, though. :-/ Link to comment https://forums.phpfreaks.com/topic/265975-selectfocus-background-image/#findComment-1363191 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.