473,563 Members | 2,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Mar 8 '07 #1
1 5997
On 2007-03-08, ChrisW <c.******@gmail .comwrote:
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.
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).
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.
Mar 8 '07 #2

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

Similar topics

28
5713
by: Gabriel | last post by:
greetings, I want to achieve the following effect : Menu1 | Menu2 | Menu3 | Menu4 | Menu5 | I played with padding, border-width and the like and it's ok for the | . My problem is that menu1 could be longer than menu2 : Products and FAQ for example. But all lengths will be smaller than say : 800/6 (menus) pixels.
4
5083
by: Rob Freundlich | last post by:
I have some servlet-generated tabular data that I need to present, so I'm using an HTML Table. In some cases, it can be quite large. I'm flushing the servlet output every N lines to push the data to the browser as it generates, and I've used "table-layout: fixed" for the table's CSS class. It works pretty well in Netscape (7.1 and higher)...
40
4436
by: Mark | last post by:
Hello i like to make the following lay out: - 3 columns - center column = fixed width - left and right columns are not fixed and must take all the available space there is left. - left column has a background picture - right column has another background picture
1
2087
by: ChitownE | last post by:
Here's what I'm looking to do: fixed left column and a right column that fills the remainder of the space. I need the ability to position other elements relative to the borders of the right column. Without nesting containers, here's the best cross-browser version I could come up with: http://www.singley.org/test/two_cols2.html I see...
8
4787
by: knoxautoguy | last post by:
This problem has consumed a lot of my time, and I'm aftraid someone will tell me that my whole approach to this objective is wrong; however, I would like to know if there is a way to do this. I have a web page divided into two major segments, with the top segment fixed and the bottom segment allowed to scroll, thus giving the look of frames...
2
3922
by: JD | last post by:
Hi, I am preparing a report in HTML. I used fixed length cells by specifying the width attribute in <td>. However for some text, the cells doesn't stick to the size specified. The expected effect should be that the text should wrap to the next line, but it doesn't. Can anybody help me to get around with this problem?
3
3842
by: jerrygadd | last post by:
Hi can anyone please help? I have a need to make a table of fixed size, containing three rows, where the middle row auto expands to fill the remaining space between the top and bottom rows. Here is what I have so far, unfortunately using height:100% for the middle row blows the size of the table! <html> <head> <title>Auto expanding...
0
1807
by: labmonkey111 | last post by:
I'm trying to get a list of page links for a report, and I'm running into a problem with IE. I have a group of nested left-floating DIVs for the page menu, inside a table. Firefox expands the size of the table to see the entire menu, but IE does not, the last few are cut off. After a couple of hours of testing, I have determined that IE is not...
0
1699
by: nlindsay | last post by:
I am trying to center align 2 left floated divs within a % width background. I know that setting the wrapper div to a fixed width works, but can it be done with a fluid background? (basically I want 2 fixed width divs to center on a background image that stretches across the whole screen). thanks
0
7665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8106
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...
1
7642
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...
0
7950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
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...

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.