0

I'm Designing a website which involves slideDown.

Initially i have set up a template which looks like the image belowSlideDownBefore

When i hover over each black blocks a ul list will be displayed... But a problem arises when i hover... All the content below the block moves down (This is illustrated in the following figure)

After SlideDown

I cant give the position to be absolute because all the content above and below are floating (They Don't have a fixed height). So what else can be done to get a slideDown by holding the rest of content there and by displaying the hover content over the text?

3
  • Have you tried placing each block on a unique z-index? Commented Apr 17, 2012 at 13:05
  • @Jay Op didn't understand where and how to use absolutely positioned elements in combination with floats, so obviously no Commented Apr 17, 2012 at 13:29
  • i'm not trying to use a float... i mean the content above this doesnt have a fixed height... they expand with content Commented Apr 17, 2012 at 13:34

2 Answers 2

1

To achieve what you want you should slideDown() an inner submenu element instead of the block itself. Consider this sample markup:

​<div class="item" id="mybox">floating box <ul class="submenu" style="display: none;"> <li>Subitem 1</li> <li>Subitem 2</li> <li>Subitem 3</li> </ul> </div> <p>More content... Just to illustrate</p> <p>More content... Just to illustrate</p>​​​​​​ 

The CSS would be something like:

.​item { position: relative; /* to hold absolutely positioned submenu inside */ background: #2684b7; color: #fff; padding: 10px; float: left; } .item .submenu { position: absolute; /* the menu would go on top of everything */ background: #2684b7; width: 100%; left: 0; } p { clear: both; } 

And finally the JavaScript is simple, just don't forget to bulletproof your animation: ​

$('#mybox').hover( function() { /* mouseover */ $(this).find('.submenu').slideDown(); }, function() { /* mouseout */ $(this).find('.submenu').slideUp(); }​​​​​ ); 

Here's the example on jsFiddle: http://jsfiddle.net/zxrvC/

Good luck. ​

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

6 Comments

the thing is i cant afford it to be positioned absolutely... All content are floating... they dont have a fixed width...
What do you mean? My solution doesn't have fixed width. An absolutely positioned element shrinks to fit the content inside it. I only position the popup menu relatively to it's parent block.
Have you actually tried my solution? If it doesn't work, please provide an example when it fails.
Thanks Dmitry... Your Solution has partially worked :-)... Only Problem is the effect of slow slideDown is not working... What should i do for that?
What do you mean? Just call slideDown('slow') or pass number of milliseconds to the function, what's not working?
|
0

Make a div with position: relative and z-index:55 and inside that div add a new div with position: absolute and also give width. Hope this will solve.

Regards

iijb

1 Comment

the thing is i cant afford it to be positioned absolutely... All content are floating... they dont have a fixed width...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.