Forum Moderators: not2easy

Message Too Old, No Replies

Can the Div tag make the page height relative not fixed?

Div Tag page height

         

Coxie

11:40 am on Sep 19, 2006 (gmt 0)

10+ Year Member



Can anyone suggest how I can specify the height of my Div style below so that the height is Auto similar to what is possible with tables?

I want pages to adjust to a height relative to the amount of content in a page. I dont want a fixed height. This is possible with tables but can you do it using the div tag?

Here is my first line of code:

"div id="Table_01" style="position:relative;width:780px;height:956px;background-color:#fff;-adbe-g:m;"

Certain pages on my site will be .asp and the results returned from a query will not always be the same amount of content. I am finding that if the page is not long enough, this content sits over the top of the bottom of my page and looks funny.

Can anyone suggest the correct code that I should use?

icantthinkofone

1:09 pm on Sep 19, 2006 (gmt 0)

10+ Year Member



I'm probably misunderstanding something but you don't need to use position:relative and just remove the height attribute.

Also, using asp has no effect on how this would work.

penders

1:17 pm on Sep 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do not specify a height for your DIV - your DIV should then size to its contents. If the DIV is then overlapping other content in your page (ie. the footer) then the layout of those other elements may need to change.

(as above - I was a bit slow in posting!)

Coxie

1:27 am on Sep 20, 2006 (gmt 0)

10+ Year Member



Thanks for the suggestions.

This div tag makes up the entire page width and height and once I remove the height from the code supplied earlier I am unable to see anything left on the page?

Viewing it in the browser shows me all the items are still there but it has removed the white background which makes up the page altogether.

SuzyUK

7:34 am on Sep 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Coxie, and Welcome to WebmasterWorld!

if you can't see it after removing the height, that suggests to me that everything inside this particular div is either floated or absolutely positioned (AP'd) in which case your Table_01 div doesn't know it's got anything in it?

Floats and AP'd elements are removed from the flow

if the contents are floated you need some way of clearing said floats and if it's all AP'd then you should rethink the layout, you will not be able to get the outer wrapper to know what is "stuck on top" of it