问题
I can't figure this out..hopefully someone else can.
I have an image button . The hover effect works fine. However, I have the IE broken image icon over the button image.
Lookie here: Funky Image Funky Image Hover
As you can see...they both work except for that annoying broken image.
Here's my CSS:
.donate-btn{ background: transparent url(/custom/img/donate-btn.png) no-repeat; overflow:hidden; height:45px; width:210px; float:left; } .donate-btn:hover{ background: transparent url(/custom/img/donate-btn.png) no-repeat; height:45px; width:210px; background-position: 0 -45px; }
回答1:
This simply means you are referencing a non-existent image in the source
attribute. You should consider using the actual <button>
tag instead. It just needs a few extra style attributes to remove borders and padding:
.donate-btn{
background: transparent url(/custom/img/donate-btn.png) 0 0 no-repeat;
overflow:hidden;
height:45px;
width:210px;
border: none;
padding: 0;
float:left;
}
.donate-btn:hover{
background-position: 0 -45px;
}
I also simplied your CSS by removing some unnecessary styling in the hover state.
<button class="donate-btn" type="submit"></button>
来源:https://stackoverflow.com/questions/1918820/css-sprites-showing-broken-image-icon-over-image-but-hover-still-works