Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

using gif as a hover effect to an area object

I’m trying to add gif by using hover effect for area map object but something is wrong here… could you please help me to solve this.

here is HTML code:

<div class="image-container">
    <img src="main_image.png" usemap="#image-map">
    <map name="image-map">
        <area href="" coords="430,432,315,292" shape="rect">
     </map>
</div>

here is CSS code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

.image-container {
            width: 1500px;
            height: 1500px;
            position: relative;
        }

area:hover {
            position: absolute;
            background-image: url('lil_dream.gif');
            z-index: 1;
        }

What’s the problem here: when I hover the area, nothing happens on the page itself but meanwhile gif appears in sources/network tabs in devtools. I made a monosnap recording, so it’s more clear -> https://take.ms/oDDkIx

Do you have some ideas what it could be?.. Thanks a lot in advance!

>Solution :

you can’t use the ‘position’ with the area element, try with ‘wrap’ inside a div, and modify the CSS adding an ‘area-wrapper’ and an ‘area-wrapper:hover’ like this:

.image-container {
    width: 1500px;
    height: 1500px;
    position: relative;
}

.area-wrapper {
    position: absolute;
    top: 292px;
    left: 315px;
    width: 115px;
    height: 140px;
}

.area-wrapper:hover {
    background-image: url('lil_dream.gif');
    z-index: 1;
}
<div class="image-container">
    <img src="main_image.png" usemap="#image-map">
    <map name="image-map">
        <div class="area-wrapper">
            <area href="" coords="430,432,315,292" shape="rect">
        </div>
     </map>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading