Jump to content

select:focus background image


DVigneault

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.