0

I have this code:

<div class="bigroundlink" >
    <img class="cross" src="img.png" style="position:absolute; display:none;" />
</div>

And would like to display that image when the user hovers the div. How can i do it ? Feel free to use/add (if needed) id's to the elements, JQuery and CSS.

4 Answers 4

5

This? (pure css)

.bigroundlink img { visibility: hidden; }
.bigroundlink:hover img { visibility: visible; }

And remove the embedded styles ons your img tag

Sign up to request clarification or add additional context in comments.

3 Comments

Edited, remove style attribute from your img tag. And prefer visibility to display, so the container keep the good dimensions
What you want is not very clear. Missing some context. Is there a reason for an absolute position? Is there a reason to show the image on hovering the div and not the image itself?
Why that? It depends context, but with display none, the div has no dimensions, and can't be hovered.
2

Works very fine with jquery!

 $(document).ready(function(){
    $(".bigroundlink").hover(function(){
        $(".bigroundlink .cross").show();
    });
 });

1 Comment

Thanks ! used this just added another param to the hover function to hide the img :) I'll edit the question with the sollution i used [btw You can accept an answer in 5 minutes, 5min :p]
2

You will need to set a width and height to the DIV if the img will not be displayed. Then:

CSS:

.bigroundlink {
    width:100px;
    height:100px;
}

jQuery:

$('.bigroundlink').hover(function(){
    $(this).children('.cross').show();
});

Comments

0

so, you need

$(function() {
$(".bigroundlink").hover(
});

and there impl .fadeTo jquery Effects

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.