2

I'm making a homepage like this: http://jsbin.com/umaguc/1/ and I'm currently working on the dropdown menu. Now what I want is to make an effect like: http://www.script-tutorials.com/demos/249/index.html; I have a div id="lavalamp" which has width, height and background color (looks like a rectangle); when I hover one of #nav ul li element (like Home, Game Offline, Game Online, Esport, Music ...) i want this #lavalamp div to be moved and changed its width so that it will looks like the effect I mentioned above. This is the idea for my code:

#nav li:nth-of-type(1):hover ~ #lavalamp {
    left: 39px;
}

#nav li:nth-of-type(2):hover ~ #lavalamp {
    left:110px;
    width:110px;
}

but sadly it's just not work. When I hover over an #nav ul li element, nothing changes ! Hope you guys can have me with this problem .. Thanks a lot !

4
  • 2
    Could you post the html you are using? Commented Jul 30, 2013 at 12:51
  • Sorry ^^ I've just updated the html & css I'm using in the jsbin link. Commented Jul 30, 2013 at 13:05
  • 2
    Check on script-tutorials.com/pure-css3-lavalamp-menu, like raddevon said it looks like your lavalamp div isn't where it should be. Commented Jul 30, 2013 at 13:16
  • Ok, i fixed it and everything works nicely. Thanks a lot ! Commented Jul 30, 2013 at 13:39

1 Answer 1

1

It looks like you've used a general sibling selector to select #lavalamp, but that element never appears as a sibling of your li element.

Unfortunately, I don't believe CSS has a way for you to climb back up the DOM to get to your #lavalamp from the lis. You could use jQuery, or you could think about ways to restructure your markup that would make the element accessible through pure CSS.

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

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.