0

I am trying to create a tool tip on my buttons. I have written the following code, it gives a little circle on mouse hover, but it disappears the original circle. Is there any way that I can hold the big Circle on mouse hover and display the little circle?

<style>

    #item
    {
        background-color: red;
        border-radius:50%;
        width:100px;
        height:100px;
        position:absolute;
        top:50px;

        }

    #item:hover
    {
        background-color:black;
        width:30px;
        height:30px;
        border-radius:50%;
        position:relative;
        top:0px;    

        }   


</style>

</head>

<body>

<div id ="item">

</div>

</body>
1
  • Yes, you could do this with a pseudoelement. Commented Jun 18, 2014 at 5:17

3 Answers 3

3

Solution : solution is here

html

<div id ="item">
   <div id ="item2">
   </div>
</div>

css

#item
{
    background-color: red;
    border-radius:50%;
    width:100px;
    height:100px;
    position:absolute;
    top:50px;

    }

#item2
{
    background-color:black;
    width:30px;
    height:30px;
    border-radius:50%;
    position:relative;
display:none;
    top:0px;    

    }   
 #item:hover > #item2
{
    display:block;

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

Comments

3

do you mean like this: http://jsfiddle.net/g3yW9/

$(function(){
    $('#item').hover(function(){
        $('#tooltip').fadeIn(200);
    },function(){
        $('#tooltip').fadeOut(200);
    });
});

Comments

3

Simplest solution. Watch out for browser compatibility

Have a fiddle!

HTML

<div id ="item">

</div>

CSS

#item {
    background-color: red;
    border-radius:50%;
    width:100px;
    height:100px;
    top:50px;
}
#item:hover:after {
    content:"";
    position:absolute;
    background-color:black;
    width:30px;
    height:30px;
    border-radius:50%;
    display: block;
    margin: -10px 0 0 -10px;
}

Above is the simplest way, but seeing as you will display text in your tooltip. Something like this may be more appropriate.

Fiddle for this!

HTML

<div id="item">
    <div>This is my tooltip</div>
</div>

CSS

#item {
    background-color: red;
    border-radius:50%;
    width:100px;
    height:100px;
    position: relative;
}
#item div {
    display: none;
}
#item:hover div {
    position:absolute;
    display: block;
    bottom: -40px;
    right: -50px;
}

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.