1

I have written this code to show n hide a div on mouse hover event. Its working fine.But only problem is when div is open on mouse over event all other div and other content goes down and down as per the height of opening div, What i want exactly, the main div which I need to show and hide should be open using Z-index property such that other content should not be affected from their position. I tried a lot, but could not find any solution. please help me guys!! Here is java script code:

var $j = jQuery.noConflict();
$j( document ).ready(function( $ ) {
$j ("#citydrop").hide();
$j ("#cityclick").mouseover(function () {
$j ("#citydrop").slideDown('slow');
});
$j ("#wrapper").mouseleave(function () {
$j ("#citydrop").slideUp('slow');
});

2 Answers 2

1

add position:absolute to #citydrop then a higher z-index say z-index:2. absolutely positioned elements are removed from the normal flow of the document, Hence won't affect other elements' positioning

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

Comments

0

You need to set the #citydrop divs position to absolute and define it's place. For example.

#citydrop {
    position: absolute;
    top: 0;
    right: 0;
}

Just play around with top/right/bottom/left attributes to find a good spot. Remember to add position:relative for the #citydrop parent element so it'll stay inside it.

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.