473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

the deal with my div

hey all,
i have a plain and simple div on my page and all i've done was change the
background color to fuchsia, made the height and width 95%.

how come the div will expand width-wise the full 95% and not the height?

thanks,
rodchar
Nov 16 '06 #1
17 1250
Heights are a tricky thing, they tend to do what they wish depending on the
browser. Part of it is the way the browser interprets the page. If it
decides that the content of the page only fills 40%, you may end up with a
div that fills 95% of the 40%. A lot of it is the interpretation of heights
as in the HTML W3C specs. To say the least, height attributes are often the
bastard child and aren't treated with the same respect in the standards as
widths are.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:A7**********************************@microsof t.com...
hey all,
i have a plain and simple div on my page and all i've done was change the
background color to fuchsia, made the height and width 95%.

how come the div will expand width-wise the full 95% and not the height?

thanks,
rodchar

Nov 16 '06 #2
Hi,

rodchar wrote:
hey all,
i have a plain and simple div on my page and all i've done was change the
background color to fuchsia, made the height and width 95%.

how come the div will expand width-wise the full 95% and not the height?

thanks,
rodchar
Try setting the form's height to 100%. In some browsers the form is
considered as a rendered element, with a height and a width.

Should that fail, consider including your DIV in a one-celled table,
with a 100% width and height.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 16 '06 #3
Percentage values are based on the parent. The body height is only as high as
it needs to be, not as high as the browser's window. You'd need to add in
some javascript to read the browser window's height and then compute the
height of the div to be 95% of that value. The same is technically true of
the width value also, but the body's width defaults to the browser window's
width. So the div's parent element (document.body) just happens to be the
whole width of the browser.

"rodchar" wrote:
hey all,
i have a plain and simple div on my page and all i've done was change the
background color to fuchsia, made the height and width 95%.

how come the div will expand width-wise the full 95% and not the height?

thanks,
rodchar
Nov 16 '06 #4
Please, for the love of CSS, don't use a table to do page layout.

"Laurent Bugnion" wrote:
Hi,

rodchar wrote:
hey all,
i have a plain and simple div on my page and all i've done was change the
background color to fuchsia, made the height and width 95%.

how come the div will expand width-wise the full 95% and not the height?

thanks,
rodchar

Try setting the form's height to 100%. In some browsers the form is
considered as a rendered element, with a height and a width.

Should that fail, consider including your DIV in a one-celled table,
with a 100% width and height.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 16 '06 #5
Hi,

Jason Stearns wrote:
Percentage values are based on the parent. The body height is only as high as
it needs to be, not as high as the browser's window. You'd need to add in
some javascript to read the browser window's height and then compute the
height of the div to be 95% of that value. The same is technically true of
the width value also, but the body's width defaults to the browser window's
width. So the div's parent element (document.body) just happens to be the
whole width of the browser.
I fail to see why it's better to use JavaScript rather than a table to
do that.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 16 '06 #6
Its not what tables were meant for. Tables are meant for displaying tabluar
data. Yes it would solve this problem just as a screwdriver could be used as
a pry bar.

Using tables for page layout can cause other problems though, like CSS
styles not cascading down into the table and it could become cumbersome for
page readers for the deaf to have to read down into the <tablethen the <tr>
then the <tdjust to get to the content.

Its just not how HTML was designed. But it would work, yes.

"Laurent Bugnion" wrote:
Hi,

Jason Stearns wrote:
Percentage values are based on the parent. The body height is only as high as
it needs to be, not as high as the browser's window. You'd need to add in
some javascript to read the browser window's height and then compute the
height of the div to be 95% of that value. The same is technically true of
the width value also, but the body's width defaults to the browser window's
width. So the div's parent element (document.body) just happens to be the
whole width of the browser.

I fail to see why it's better to use JavaScript rather than a table to
do that.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 16 '06 #7
Correction. Page readers for the blind not the deaf. duh.

"Jason Stearns" wrote:
Its not what tables were meant for. Tables are meant for displaying tabluar
data. Yes it would solve this problem just as a screwdriver could be used as
a pry bar.

Using tables for page layout can cause other problems though, like CSS
styles not cascading down into the table and it could become cumbersome for
page readers for the deaf to have to read down into the <tablethen the <tr>
then the <tdjust to get to the content.

Its just not how HTML was designed. But it would work, yes.

"Laurent Bugnion" wrote:
Hi,

Jason Stearns wrote:
Percentage values are based on the parent. The body height is only as high as
it needs to be, not as high as the browser's window. You'd need to add in
some javascript to read the browser window's height and then compute the
height of the div to be 95% of that value. The same is technically true of
the width value also, but the body's width defaults to the browser window's
width. So the div's parent element (document.body) just happens to be the
whole width of the browser.
I fail to see why it's better to use JavaScript rather than a table to
do that.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 16 '06 #8
styles not cascading down into the table and it could become cumbersome
for
page readers for the deaf to have to read down into the <tablethen the
<tr>
then the <tdjust to get to the content.
Screen readers don't literally read the source code. Well formed tables
shouldn't be much of an accessibility issue.

That said, CSS does have many advantages.

-Darrel
Nov 16 '06 #9
Hi,

Jason Stearns wrote:
Its not what tables were meant for. Tables are meant for displaying tabluar
data. Yes it would solve this problem just as a screwdriver could be used as
a pry bar.

Using tables for page layout can cause other problems though, like CSS
styles not cascading down into the table and it could become cumbersome for
page readers for the deaf to have to read down into the <tablethen the <tr>
then the <tdjust to get to the content.

Its just not how HTML was designed. But it would work, yes.
I agree. But getting the window's size with JavaScript is also a bad
tool. Out of two bad tools, I prefer the one which works also without
JavaScript ;-)

Just my opinion, of course.

BTW, in IE, setting the height of the body to 100% solves the problem.
In Firefox it doesn't (at least not on Windows).

Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 16 '06 #10
I agree. But getting the window's size with JavaScript is also a bad tool.

How so? Seems that Javascript is the more applicable tool for this.

Even with tables, 100% height isn't technically a standard (even though some
browsers do support it).

Personally, I'd just give the DIV a specific height and live with it. I try
to avoid worrying about how tall the viewport is...let the page be as long
as it needs to be.

-Darrel
Nov 16 '06 #11
Good point. I do generally focus on Firefox first, then tweak for IE.
Something i just tried and it worked ok in both FF2.0 and IE6 is

<HEAD>
<style>
BODY
{
min-height:100%;
}
</style>

</HEAD>

<BODY>
<div style="height:100%; border:black solid 1px;">
TEST
</div>
</BODY>

"Laurent Bugnion" wrote:
Hi,

Jason Stearns wrote:
Its not what tables were meant for. Tables are meant for displaying tabluar
data. Yes it would solve this problem just as a screwdriver could be used as
a pry bar.

Using tables for page layout can cause other problems though, like CSS
styles not cascading down into the table and it could become cumbersome for
page readers for the deaf to have to read down into the <tablethen the <tr>
then the <tdjust to get to the content.

Its just not how HTML was designed. But it would work, yes.

I agree. But getting the window's size with JavaScript is also a bad
tool. Out of two bad tools, I prefer the one which works also without
JavaScript ;-)

Just my opinion, of course.

BTW, in IE, setting the height of the body to 100% solves the problem.
In Firefox it doesn't (at least not on Windows).

Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 16 '06 #12
Hi,

darrel wrote:
>I agree. But getting the window's size with JavaScript is also a bad tool.

How so? Seems that Javascript is the more applicable tool for this.
Because it's not cross browser compatible (at least not in my
experience, and I'd love to be proven wrong, so don't hesitate ;-)

http://www.howtocreate.co.uk/tutoria.../browserwindow

And also because JavaScript is sometimes disabled. I rely on JavaScript
(and people who know me know that I relied on it for a very long time,
see comp.lang.javascript archives). I use it to improve the user
experience, but the most important thing for me is that it must
absolutely degrade gracefully. In other words, if it's not available, I
want the user to notice as little as possible, and unfortunately when
you use it to set the layout, he does notice.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 16 '06 #13
Hi,

Jason Stearns wrote:
Good point. I do generally focus on Firefox first, then tweak for IE.
Something i just tried and it worked ok in both FF2.0 and IE6 is

<HEAD>
<style>
BODY
{
min-height:100%;
}
</style>

</HEAD>

<BODY>
<div style="height:100%; border:black solid 1px;">
TEST
</div>
</BODY>
Oh, something came to my mind, and I tested again with the body height
set to 100%. It works fine with HTML 4.0 transitional DOCTYPE in both
IE6 and FF1.5.

However, even min-height fails in IE6 and FF1.5 with DOCTYPE set to XHTML...

Also, if the DIV is enclosed in a form, the form's height must also be
set to 100%.

OK, that's really off topic now.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 16 '06 #14
And also because JavaScript is sometimes disabled. I rely on JavaScript
(and people who know me know that I relied on it for a very long time, see
comp.lang.javascript archives). I use it to improve the user experience,
but the most important thing for me is that it must absolutely degrade
gracefully. In other words, if it's not available, I want the user to
notice as little as possible, and unfortunately when you use it to set the
layout, he does notice.
I agree, though I don't see that 'enhancing layout' is not an applicable use
of javascript. Provided the markup is semantic, accessible, and is usable
without javascript, I'm fine with that.

-Darrel
Nov 16 '06 #15
Writing javascript to do x for one browser and y for another isn't hard, just
time consuming and requires good testing. But i don't think that any asp.net
application could be expected to run correctly with out javascript enabled on
the client side. As far as i'm concerned if you don't have javascript enabled
you're just not going to be able to function on today's web.

rodchar, if i were you i would just read up on the w3c specs and do what
ever works for you. there's lots of documentation on the benefits of
tableless css design, but a table would fix this problem also.

"Laurent Bugnion" wrote:
Hi,

darrel wrote:
I agree. But getting the window's size with JavaScript is also a bad tool.
How so? Seems that Javascript is the more applicable tool for this.

Because it's not cross browser compatible (at least not in my
experience, and I'd love to be proven wrong, so don't hesitate ;-)

http://www.howtocreate.co.uk/tutoria.../browserwindow

And also because JavaScript is sometimes disabled. I rely on JavaScript
(and people who know me know that I relied on it for a very long time,
see comp.lang.javascript archives). I use it to improve the user
experience, but the most important thing for me is that it must
absolutely degrade gracefully. In other words, if it's not available, I
want the user to notice as little as possible, and unfortunately when
you use it to set the layout, he does notice.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 16 '06 #16
Hi,

Jason Stearns wrote:
Writing javascript to do x for one browser and y for another isn't hard, just
time consuming and requires good testing.
Additionally, cross-browser coding is also not that hard, and more and
more possible, except for minor functionalities like the one we're
talking about.
But i don't think that any asp.net
application could be expected to run correctly with out javascript enabled on
the client side. As far as i'm concerned if you don't have javascript enabled
you're just not going to be able to function on today's web.
I think that's true for thick clients. However, don't forget all the
users (more and more each day) who access your page using mobile
devices, where only a subset (at best) of JavaScript is available.
Irrelevant point in our case, since the layout issue on a mobile device
is totally different anyway.

rodchar, if i were you i would just read up on the w3c specs and do what
ever works for you. there's lots of documentation on the benefits of
tableless css design, but a table would fix this problem also.
Pragmatism and compromise are the two most important attitudes in
today's world of software engineering. I concur :-)

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 17 '06 #17
As far as i'm concerned if you don't have javascript enabled
you're just not going to be able to function on today's web.
In reality, that's true. In theory, it shouldn't be.

Javascript should always be treated as an 'enhancement' to the user
experience...not a requirement.

one of the major benefits of the web is the ability to make it accessible to
a much wider audience than any other medium that has come before it. Even
(oddly enough) Microsoft seems to be accepting this as the better way. It
sounds like ASP.net 2.0 and Atlas not only now support a wider range of
browsers, but Atlas has also been designed so that it can gracefully degrade
for those without javascript if one builds the site correctly.

-Darrel
Nov 17 '06 #18

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

Similar topics

6
by: Alex Shi | last post by:
Any good idea or a reference link to deal with search engine for php web pages? Thanks in advance! Alex
9
by: _mario lat | last post by:
I'd like to deal (update, deal, insert....) a database (with tables and relationship between these) by a tool written in php. I need to share and work on a database with other people. I'd like to...
6
by: christian9997 | last post by:
Hi We have started off using a $_GET parameter to keep track of the user's browser: We detect what browser the visitor is using when he first arrives on our website then we do a redirect to...
1
by: Davy | last post by:
My program deal with a several level tree with several branchs. The amount of branchs from father node is not known. So I want to creat a tree with dynamic branchs. Now I use the structure:...
5
by: Amr | last post by:
Hi i need a library to deal with the modem, cause i have to make an application that connect to the modem and deal a number, and wirte the events (busy, answered, not answered)
7
by: rbt | last post by:
The house almost always wins or are my assumptions wrong... import random amounts = results = count = 0 while count < 10:
48
by: Frederick Gotham | last post by:
The "toupper" function takes an int as an argument. That's not too irrational given that a character literal is of type "int" in C. (Although why it isn't of type "char" escapes me... ) The...
7
by: rockdale | last post by:
Hi, How do you guys deal with the different clinet resolution? For example, you have 800*600, 1024*768 and 1280*1024 on client side. We used to put everything into a table with fixed width (the...
10
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Which newsgroups deal with javascript? ----------------------------------------------------------------------- ...
0
by: AWHF | last post by:
hey, is there anyone who know how to deal with vector? i have 2 files as below: file1.doc ::component list ::Start green in grp1 blue in grp2
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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...

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.