Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 8th, 2007, 02:25 PM
ChrisW
Guest
 
Posts: n/a
Default Fixed width and relative nested divs

Just out of interest, does anyone know what the behaviour of the
following is supposed to be:

<div style="width: 80%">

<div style="width: 600px">

<!--HTML code goes here -->

</div>

</div>

If the users' screen size is, for example, 1280x1024, then the nested
div will no doubt just sit comfortably in the outer div. However, if
the users' screen size is set to something like 800x600, 80% of the
screen size will be 480px, which is obviously less than the nested
div's width.

This might be a strange thing to ask, but GoogleMaps requires the map
to be loaded into a div, with an id attribute set to, for example,
"map"

e.g: <div id="map" style="width: 650px; height: 725px;
padding:-5px;"></div>

The width and height need to be absolute values - since GoogleMaps is
based wholly on JavaScript, the map is loaded in the body tag, I'm not
sure if it's recommended to (although I'm sure it's possible) to
dynamically change the size of the map based on the current size of
the screen. Essentially, what I'm saying is that I've been brought up
on the importance of relative sizes for all types of elements, hence
why I wanted to nest the div in one that had a relative width, but I'm
not sure what the outcome will be!

Thanks in advance,

Chris

  #2  
Old March 8th, 2007, 02:35 PM
Ben C
Guest
 
Posts: n/a
Default Re: Fixed width and relative nested divs

On 2007-03-08, ChrisW <c.c.wood@gmail.comwrote:
Quote:
Just out of interest, does anyone know what the behaviour of the
following is supposed to be:
>
><div style="width: 80%">
>
<div style="width: 600px">
>
<!--HTML code goes here -->
>
</div>
>
></div>
In most cases the outer div's width will be 80% of its container's
width, and the inner div will be 600px wide. If that turns out to be
bigger than its container then it overflows, and there's an overflow
property you can set to say whether it should be clipped, just stick
out, or be given a horizontal scrollbar.
Quote:
If the users' screen size is, for example, 1280x1024, then the nested
div will no doubt just sit comfortably in the outer div. However, if
the users' screen size is set to something like 800x600, 80% of the
screen size will be 480px, which is obviously less than the nested
div's width.
In that case it overflows. The general rule is that a block-level
element's width comes from its containing block, and has nothing to do
with the widths of its descendents. The exceptions are elements with
auto shrink-to-fit widths (floats, table cells, tables, absolutely
positioned boxes).
Quote:
This might be a strange thing to ask, but GoogleMaps requires the map
to be loaded into a div, with an id attribute set to, for example,
"map"
>
e.g: <div id="map" style="width: 650px; height: 725px;
padding:-5px;"></div>
>
The width and height need to be absolute values - since GoogleMaps is
based wholly on JavaScript, the map is loaded in the body tag, I'm not
sure if it's recommended to (although I'm sure it's possible) to
dynamically change the size of the map based on the current size of
the screen. Essentially, what I'm saying is that I've been brought up
on the importance of relative sizes for all types of elements, hence
why I wanted to nest the div in one that had a relative width, but I'm
not sure what the outcome will be!
Try it and see, it works OK, although you may end up with a horizontal
scrollbar appearing on the main browser window.
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles