Changing the position of the block when you hover over the link

The question was asked: 6 years 9 months ago views: 24

0

In the layout menu of this type

when you hover over a menu item it "slides" up. On the last menu item, sitting birds, they made some miracle with absolute positioning. You need to hover on the last menu item the birds are raised together with him.
I was able to write a script so that when hovering over block was raised

Answers 1

0

The answer is a question to ponder. Here you can use jquery in order to catch the hover of the menu items to filter the last point, further change the style of the block with the birds - positioning. Look at the event "unhover" and to restore the status quo. Yes, you can. What if...

Take the block with the birds and put it inside the last element of the menu. Styles to position it absolutely to the menu item linking to the top menu. And on :hover the menu item to change the height of this menu item. And the birds will go for the menu. Because it is always tied to the top of the menu, not hats in General. And as if javascript is not needed :)

UPD: regarding the script. If he has only the task to move the bird, then loop through all the menu items nav.each(function(index){})too. as for all items, only checked the index and nothing is done. A desired filter is initially LI and it will apply the hover.

Or $("#navigation ul li").last() / $("#navigation ul li").filter(':last') provided that birdie on the last menu item sits. Or $("#navigation ul li").get(4) if the bird is in fifth menu item. And already for this item will be able to add hover tracking. do not force the browser to do unnecessary things if possible. Proffit from this Udet at the end of the project in the form of a faster website and less angry users on the buggy site :)