473,831 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Full Height DIV Mystery

OK folks, I know this has seemingly been discussed to death but
honestly, I could not find posts related to the specific problem I'm
submitting here. Feel free to flame me, as long as you provide a link
;)

The scenario is simple: An XHTML 1.0 page in Strict Mode. A single DIV
for the content. I want this DIV to occupy the full height of the
viewport.

A somewhat satisfactory prototype is here:
http://novodom.net/test.html

This behaves as I expected, in Firefox and IE. There's a mysterious bit
of vertical scrolling that I can live with.

Problems arise here:
http://novodom.net/test2.html

This is _exactly_ the same code, but with much more content. IE behaves
as I expected but Firefox gets weird on me: the background-color of the
DIV seems to stop at the viewable area's edge! So when I scroll down,
the content is presented according to all CSS rules of the DIV
(padding, etc), except background-color! (Please view the example above
for a better understanding).
Any explanation, solutions or tips will be greatly appreciated!

Jul 21 '05 #1
8 20874
In your #myDiv statement in your CSS, remove the height: 100%; and it
should stretch accordingly. When setting the height like that, Firefox
interprets that as 100% of the browser window, not 100% of the content.
Removing the height attribute should fix the problem.

Jul 21 '05 #2
Original :: musicinmyhead :: 2004-12-09 20:54
In your #myDiv statement in your CSS, remove the height: 100%; and it
should stretch accordingly. When setting the height like that, Firefox
interprets that as 100% of the browser window, not 100% of the content.
Removing the height attribute should fix the problem.

Sorry but this solution doest not work for the first scenario: the div
adjusts its length to the content, so it's about an inch tall and
doesn't stretch to the bottom of the page.

I've also tried using 'min-height'; that worked great in Mozilla, did
not work in IE.

Any other ideas?
Jul 21 '05 #3
Ah ok, yeah I read your question wrong, I was thinking your problem was
just with it not scrolling all the way, when it's just the old "won't
stretch with less content" problem. In which case I can never remember
how to fix that, so I usually just don't bother.

Good luck though.

Jul 21 '05 #4
Hi,

Terry wrote:
Original :: musicinmyhead :: 2004-12-09 20:54
In your #myDiv statement in your CSS, remove the height: 100%; and it
should stretch accordingly. When setting the height like that, Firefox
interprets that as 100% of the browser window, not 100% of the content.
Removing the height attribute should fix the problem.

Sorry but this solution doest not work for the first scenario: the div
adjusts its length to the content, so it's about an inch tall and
doesn't stretch to the bottom of the page.

I've also tried using 'min-height'; that worked great in Mozilla, did
not work in IE.

Any other ideas?


Two ideas: Either use Dean Edwards' IE7 patch to let IE understand
min-height or try to place an empty div with 100% height in #myDiv.
But I fear the latter won't do it (since it has 100% of #myDiv as
height...).

Chris
Jul 21 '05 #5
Hi,

Chris Leipold wrote:
Hi,

Terry wrote:
Original :: musicinmyhead :: 2004-12-09 20:54
In your #myDiv statement in your CSS, remove the height: 100%; and it should stretch accordingly. When setting the height like that, Firefox interprets that as 100% of the browser window, not 100% of the content. Removing the height attribute should fix the problem.

Sorry but this solution doest not work for the first scenario: the div adjusts its length to the content, so it's about an inch tall and
doesn't stretch to the bottom of the page.

I've also tried using 'min-height'; that worked great in Mozilla, did not work in IE.

Any other ideas?


Two ideas: Either use Dean Edwards' IE7 patch to let IE understand
min-height or try to place an empty div with 100% height in #myDiv.
But I fear the latter won't do it (since it has 100% of #myDiv as
height...).

Chris

I've taken another approach that shows some promise but I STILL need
help, please.

I need a full-width header on top of the page and *then* a narrower
content area.

I've decided to play with the margins of the BODY element and you can
see the result i'm hoping for here, if you use Mozilla:
http://novodom.net/test3.html

That's exactly what I'm after -- the only thing left to do is to make
it work in IE. IE does show everytning in the right place, but the
width of the header is not what I expected.

Can someone explain or suggest tips for dealing with the header width
sot that it spreads across the whole page?
Thanks again.

Jul 21 '05 #6
> I've taken another approach that shows some promise but I STILL need
help, please.

I need a full-width header on top of the page and *then* a narrower
content area.

I've decided to play with the margins of the BODY element and you can
see the result i'm hoping for here, if you use Mozilla:
http://novodom.net/test3.html

That's exactly what I'm after -- the only thing left to do is to make
it work in IE. IE does show everytning in the right place, but the
width of the header is not what I expected.

Can someone explain or suggest tips for dealing with the header width
sot that it spreads across the whole page?
Thanks again.


Ok there are a few things you can change to make this work. First off
wrap all of your content in a div and give it an ID, for instance #all.
Then make sure the header is at the top outside of the #all div so that
the margins for #all don't affect the header. Then in your css, change
the body to #all and change the html to "HTML, BODY" instead.

You can see an example here of what I changed:
http://hfd.mine.nu/full_width_header.html

And just another note, in your #myDiv css you gave it a z-index yet it
was positioned relatively. When you do that the browser will ignore the
z-index, because it only works with absolutely positioned elements.

Jul 21 '05 #7
Hi again!

musicinmyhead wrote:
I've taken another approach that shows some promise but I STILL need help, please.

I need a full-width header on top of the page and *then* a narrower
content area.

I've decided to play with the margins of the BODY element and you can see the result i'm hoping for here, if you use Mozilla:
http://novodom.net/test3.html

That's exactly what I'm after -- the only thing left to do is to make it work in IE. IE does show everytning in the right place, but the
width of the header is not what I expected.

Can someone explain or suggest tips for dealing with the header width sot that it spreads across the whole page?
Thanks again.
Ok there are a few things you can change to make this work. First off
wrap all of your content in a div and give it an ID, for instance

#all. Then make sure the header is at the top outside of the #all div so that the margins for #all don't affect the header. Then in your css, change the body to #all and change the html to "HTML, BODY" instead.

You can see an example here of what I changed:
http://hfd.mine.nu/full_width_header.html

And just another note, in your #myDiv css you gave it a z-index yet it was positioned relatively. When you do that the browser will ignore the z-index, because it only works with absolutely positioned elements.

Very nice! When I tried it with lots of text, the #all DIV did not keep
up with the scrolling (same symptom as my original post).

So I applied Tantek's hack and voilà!
http://novodom.net/solution_A.htm

Now, the look is the same in both browsers (with IE displaying a
vertical scrollbar for some reason?!) and this will enable me to go
forward with this design I wanted!

Thanks to all who contributed. I hope to repay the favor if I ever get
the chance!

Jul 21 '05 #8
Hi,

Original :: Chris Leipold :: 2004-12-10 04:45
Hi,

Terry wrote:
Original :: musicinmyhead :: 2004-12-09 20:54
In your #myDiv statement in your CSS, remove the height: 100%; and it
should stretch accordingly. When setting the height like that, Firefox
interprets that as 100% of the browser window, not 100% of the content.
Removing the height attribute should fix the problem.

Sorry but this solution doest not work for the first scenario: the div
adjusts its length to the content, so it's about an inch tall and
doesn't stretch to the bottom of the page.

I've also tried using 'min-height'; that worked great in Mozilla, did
not work in IE.

Any other ideas?


Two ideas: Either use Dean Edwards' IE7 patch to let IE understand
min-height or try to place an empty div with 100% height in #myDiv.
But I fear the latter won't do it (since it has 100% of #myDiv as
height...).

Chris


I've taken another approach that shows some promise but I STILL need
help, please.
I need a full-width header on top of the page and *then* a narrower
content area.
I've decided to play with the margins of the BODY element and you can
see the result i'm hoping for here, if you use Mozilla:
http://novodom.net/test3.html

That's exactly what I'm after -- the only thing left to do is to make it
work in IE. IE does show everytning in the right place, but the width of
the header is not what I expected.

Can someone explain or suggest tips for dealing with the header width so
that it spreads across the whole page?
Thanks again.
Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
12233
by: Graham J | last post by:
Apologies for the partial post that mysteriously escaped as I was composing. I shall try again. For many years I have been happily and successfully coding tables such that the WIDTH specified in a TD is the complete column width including any CELLPADDING. For example for a 400 pixel wide table with four 100 pixel wide columns and 10 pixel cellpadding... <TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="10">
2
5907
by: tomasio | last post by:
dear group, as nobody answered my recent posts (maybe they were too complicated) i just ask you to help me on a rather simple issue: how can i stretch divs to the full height of the viewport (in my case the browser window)? any help will be appreciated. -- kind regards,
2
4414
by: Larry R Harrison Jr | last post by:
I have pull-down menus in javascript and I have the code for opening a link in a new window. But I want it to open a full-sized window. I can't figure out the syntax. What I have so far: Menu5_5_1=new Array("'Lonely Church","javascript:window.open ('http://www.photo.net/photodb/photo?photo_id=2640310')","",0,20,300); That works fine, except I can't figure out how to modify it to make it open full-screen.
6
5623
by: Tony Liu | last post by:
Hi, when switched to the full screen mode in VS.NET IDE, is there any way to hide the main menu bar? Thanks Tony
1
2094
by: avocado12 | last post by:
Hi, I'm pretty new to web development and I just spent the better part of the morning trying to figure out this IE bug. I came up with a hack that makes no sense to me. I would appreciate if someone could explain why this situation occurs, and if there is a better solution! I am trying to stack 2 divs on top of each other. The divs should be 5 pixels tall and touching each other. (In my website, these are actually containers for top and...
6
4785
by: Jeff | last post by:
Nearly identical post in alt.www.webmaster, where it is languishing. I'd like a column that flows the full height of a page, even if you scroll down. If I did this: <div style="width: 100px;height=100%;background-color: red">
5
1767
by: tader | last post by:
Hi again, so i got another question this time i need to get full web height but i just can't do it can anyone help me plz i try to use innerHeight, screen.availHeight and so on but thous function get me height that i can see not full height with scrollbars so how to get height full web height??? i hove you understand me i you don't write i will try to explane again
6
11910
by: hdsk | last post by:
hi everybody, this is my first time posting something. And I'm sorry because my english is far from perfect. I'm trying to make a fullscreen transparent div but I have some restrictions on the way to do it. My div should be inside another div. As the containig div isn't full screen I think the inside div can't be full screen. . . . I try to achive this in several steps to reduce complexity. The first step was to make a transparent 100%...
3
1867
dmjpro
by: dmjpro | last post by:
I am using this JavaScript code to open a window in a full screen mode .... var styles = "menubar=no,location=no,resizable=no,scrollbars=yes,status=no,left=0,top=0,width="+screen.width+",height="+screen.height; alert('Width: ' + screen.width + 'Height: ' + screen.height); var _win = window.open("welcome.jsp","opener_window",styles); Now it's working properly in IE but not working in Mozilla. In Mozilla, first of all it's having the...
0
10778
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10496
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10538
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6951
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3077
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.