2

I want to show second div (in HTML) with class dikha on cursor hover over anchor tag.

HTML CODE:

<a>Hover over me!</a>
<div class="faraz"> sdjfg </div>
<div class="dikha">Stuff shown on hover</div>

STYLE

div {
display: none;
}

a:hover > div:nth-child(2) {
display: block;
background-color: RED;
height: 250px;
width: 960px;
}

3 Answers 3

6

Write like this:

a:hover ~ .dikha {
    display: block;
    background-color: RED;
    height: 250px;
    width: 960px;
}
Sign up to request clarification or add additional context in comments.

Comments

3

You need to use the adjacent siblings selector ~. Also, the div you want to show is the third child, not the second (because the <a> is the first).

div {
    display: none;
}
a:hover ~ div:nth-child(3) {
    display: block;
    background-color: RED;
    height: 250px;
    width: 960px;
}

Demo: http://jsfiddle.net/3eFhf/

1 Comment

Thanks it worked. another problem i was having is with DREAMWEAVER it wasnt showing exact results. thanks
-1

you can use javascript function here.

< onmouseover="document.getElementById('myid').style.display='block'">

< id="myid" class="dikha">

Your dikha class should be hidden by default

.dikha { display:none; }

you can also use jquery slidetoggle method to achieve this

2 Comments

question stands for "using css and html only"
sorry i mentioned in question heading that i only require it to be done using css n html.. thanks

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.