简体   繁体   中英

HTML CSS Hover Image Link with One Image

User Alois Madhal posted an awesome piece of advice for someone trying to create a hover image. I would like to use this same technique but as an image link. Is it possible? I've tried all sorts of ways but think I must be missing something obvious. Here is the info Alois provided:

 <style>
    #tuxie {
        width: 25px; height: 25px;
        background: url('images/tuxie.png') no-repeat left top;
    }
    #tuxie:hover { background-position: -25px 0px }
</style>

<div id="tuxie" />

Absolutely.

All you need to do is use <a href="..."> as you normally would for a link.

The important thing is to add display:inline-block to the link's styles. This will allow you to apply width and height to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM