Forum Moderators: not2easy

Message Too Old, No Replies

Using CSS to control varying height DIV order?

         

IntegrityWebDev

8:03 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



I have, what is probably a pretty basic question:

On a page I want to DISPLAY:

DIV--MENU (may be varying height)
DIV--FLASH IMAGE ROTATOR (fixed height OK)
DIV--LOTS OF TEXT (may be varying height)
OTHER STUFF (may be varying height)

But in the code I want to order it

DIV--MENU (may be varying height)
DIV--LOTS OF TEXT (may be varying height)
DIV--FLASH IMAGE ROTATOR (fixed height OK)
OTHER STUFF (may be varying height)

Can anyone give me pointers on this?

Thanks!
Chris

limbo

10:36 am on Jan 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tricky one.

Are all the containers the same width?

My first thought was to use relative positioning but the flexible height of 'lots of text' would make that impossible, as you'd need to know it's height. You could use Javascript to calculate the height of 'lots of text' and apply inline styles to the 'flash image rotator' with Z-index and floats, but it wouldn't be ideal.

Out of interest, what is the reason why? Getting the content up to the top for SE's?

IntegrityWebDev

1:29 pm on Jan 6, 2010 (gmt 0)

10+ Year Member



Yes getting the content up higher, above the flash content, is the main reason...but maybe thats not very important? Yes all divs are fixed width.

limbo

2:20 pm on Jan 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does it even make sense to put the content first? Is that not a myth?

So what method are you using to display your Flash? The SWFobject method is very low key. One .js file and minimal html.

None of that re-solves the first goal, mind you. I'll do some digging about, as I'm sure there's a cross-browser method out there for content positioning with flexible spacing...

[Edited for brevity]

[edited by: limbo at 2:56 pm (utc) on Jan. 6, 2010]

limbo

2:52 pm on Jan 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've just run a preliminary test in FF and IE7/8.

Using position:fixed and setting the distance from the top of the page seems to do the trick for the flash box (with a fixed height).

A bit like this (excuse the quick and dirty inline styles):

<body style="width:800px;margin:0 auto;">
<div style="width:800px; background:#eee; height:50px;float:right">header</div>
<div style="width:800px; background:#ccc;position:fixed;top:150px;">
<div>Content</div>
<div style="width:800px; background:#bbb;">Other Stuff</div>
<div style="width:800px; background:#aaa;">Footer</div>
</div><!-- end of div containing all elements apart from flash -->
<div style="width:800px; background:#ddd; height:100px;position:fixed;top:50px;">Flash</div>
</body>

Not got IE6 here today - It'll probably need conditionals.

However - this method relies on header being fixed height too... The variables in height for content and header are the issue, anything following content is not as you can simply place it inside the same container as main content.

[edited by: limbo at 2:58 pm (utc) on Jan. 6, 2010]

IntegrityWebDev

2:56 pm on Jan 6, 2010 (gmt 0)

10+ Year Member



Yes flash is fixed. Thanks for the code, I will play with that!