473,473 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Vertical Stretch

2 New Member
I have this CSS layout that I'd like to use for a personal site:

I want the layout to stretch all the way from the top of the page to the bottom of the page regardless of how little content there is, or what screen resolution the user is viewing the site with. If the content won't fit on one screen, I would obviously also want the layout to stretch to accomodate the text. However, I can't seem to figure out a way to get it to do what I want, because of all the divs nestled inside one another. Any ideas?
Jun 15 '07 #1
6 9476
drhowarddrfine
7,435 Recognized Expert Expert
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>


<style type="text/css">
*{
margin:0;
padding:0;
}
html,body{
height:100%;
background-color:#efe;
}
div{
height:100%;
}
</style>

</head>
<body>
<div>
<p>Your Content</p>
</div>
</body>
</html>[/HTML]
Jun 15 '07 #2
yuiness
2 New Member
Sorry, looks like my link didn't show up correctly. Here it is: http://neogrotesque.lastsong.net/layouts/view/031/

My problem is more or less th existance of the footer divs. I can't just specify a 100% height because the footer_01 div has to have a height of the screen height minus the height of footer_02.
Jun 15 '07 #3
nitinpatel1117
111 New Member
you have to do this is javascript.

give all divs a different Id, so that you can refer to them indiviually.

Get the height of the viewable area and minus the div height of the footer to give you the target height.

then set the other div to this target height:

get/set div heights
document.getElementById('your_div_id').style.heigh t

for the height of the veiwable area, do search on goolge there are plenty of scripts out there.
Can't remember if screen.height is browser compatible, but its something along those lilnes.
Jun 18 '07 #4
drhowarddrfine
7,435 Recognized Expert Expert
You do not need javascript to do this. I'll have to look at my markup but you just put the footer in the position you normally would and give a negative margin to the footer or a wrapper div. I'll look it up later today.
Jun 18 '07 #5
drhowarddrfine
7,435 Recognized Expert Expert
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>


<style type="text/css">
*{
margin:0;
padding:0;
}
html,body
{
height: 100%;
}

#main
{
position: relative;
min-height: 100%;
}

#footer
{
position: relative;
margin-top: -1.5em;
}
</style>

</head>
<body>
<div id="main">main
</div>
<div id="footer">footer
</div>
</body>
</html>[/HTML]
Jun 18 '07 #6
nitinpatel1117
111 New Member
a small change to the above code is required as min-height is not properly supported in IE 6.

in the div 'main'; you'll need to add the height variable


#main
{
position: relative;
height:100%; //add this extra line
min-height: 100%;
}
Jun 20 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: abracad | last post by:
Hi Is it possible to vertically align an image in the middle of a DIV of fixed height?
1
by: Kenneth | last post by:
Okay, I've been scouring Google for hours looking for a solution to this problem, but as of yet I can't find one. XHTML Transitional seems to specify that I can no longer set a table's height to...
9
by: Wes Groleau | last post by:
http://www.northwestallentrails.org/testing.shtml http://www.northwestallentrails.org/newstyles.css Is there a simple way to make the nav and content boxes stretch down and touch the footer? I...
3
by: acunnon | last post by:
I am trying to put together an login page my problem is getting the three items aligned to the middle verticaly without specifing a height to anything on the page. CSS html{ height:100%;...
1
by: mactelesis | last post by:
I have searched for "vertical stretch, align, etc." and have tried (and failed) with all of the solutions to stretch the "#nav vertical" div so that it streches to the height of the page. As you can...
2
by: esteuart | last post by:
I need to get the right combination for a div to clip any text inside and allow vertical alignment. I only have this problem in FireFox. I have 3 divs nested within each other. The outer div has...
3
by: Harris Kosmidhs | last post by:
Hello. I see there is a W3C CSS2 specification for font-stretch property. I also see that no browser supports it. Why is that? And is there a work around for this? I don't want to use an image...
40
by: maya | last post by:
hi, how do I get text to vertical-align inside a div? http://www.mayacove.com/misc/home.html vertical-align should work, according to this:...
4
by: Bob Altman | last post by:
Hi all, I posted an earlier question to the microsoft.public.inetserver.asp.general newsgroup asking how to set the background of a client-side table cell to a gradient, and I received this...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.