Forum Moderators: open

Message Too Old, No Replies

Divs and overlap

Content is overlapping the edge of a div

         

Captaffy

9:21 pm on Aug 1, 2002 (gmt 0)

10+ Year Member



Picture a web page (for simplicity's sake) with nothing on it except for a div with a one pixel border.

The content on this page is displayed within the div. Unfortunately, some of the content is in a rather (horizontally) large table. If the user were to increase the font size, the table would not fit on the screen and the user would have to scroll horizontally.

In IE 5.5 (presumable 6 as well), the div increases in size with the content.
In Opera and Mozilla, the div remains the same size and the table falls over the edge. (I assume that since both Opera and Mozilla are doing it, this is the correct browser implementation...)

Is there any way to get around this problem?
With css?
With an iframe?

Thanks for any help!

Nick_W

9:26 pm on Aug 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's a bit hard to picture but my guess would be that you should drop the div. What's it there for?

Style the table.... ;)

Nick

Captaffy

9:34 pm on Aug 1, 2002 (gmt 0)

10+ Year Member



It's a bit hard to picture but my guess would be that you should drop the div. What's it there for?

It just looks nice.
I am not a terribly artistic person, so I have to rely on minimalist stylings.
I know I could do it with a table, but I hate nesting tables.

I may just scrap the whole design if I can't get it to work.

Nick_W

9:47 pm on Aug 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Post the code, with an explanation of what it *should* do ;-) and let's have a look...

Nick

moonbiter

1:50 pm on Aug 2, 2002 (gmt 0)

10+ Year Member



Try putting style="position: relative" on the div.

I think this is a bug, but this seems to work around it for the most part (except that the right margin gets hosed).

papabaer

2:10 pm on Aug 2, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is the <div> styled at all? If so, what are the style declarations?

Though not likely in your case, one fairly common problem some CSS newbies have with <div>'s is assigning a width declaration without including a unit identifier.

The following style will not allow text-wrap within the div because there is no unit identifier included:

div.no-wrap {
width:600;
}

/* text will break the right margin in the above incomplete style */

For unit values greater than zero, unit identifiers MUST be included.

div.wraps-text-nicely {
width:600px;
}

/* text will now wrap nicely! */

rewboss

3:10 pm on Aug 2, 2002 (gmt 0)

10+ Year Member



For unit values greater than zero, unit identifiers MUST be included

I'm going to be really picky here and say that it should read: "For unit values other than zero..." You can specify negative margins, for example, and there's a difference between -10em and -10px. Negative values are also important for relative positioning. (You can also specify negative percentages and rgb values for colours, but they get adjusted to zero.)

Captaffy

2:34 pm on Aug 6, 2002 (gmt 0)

10+ Year Member



Thanks for all the help. Unfortunately, I haven't been able to solve the problem.

I would have gotten back to you all sooner, but it was a long weekend here in Ontario and so I went out to nature and whatnot.

What follows is the actual code for the div, if anyone still has any interest in playing around with it. I am going to scrap the layout I think.

<div style="background-color: #fff; border: #000000 1px solid; padding: 1%;">

(I tried using 'position: relative' to no effect.)

tedster

2:45 pm on Aug 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Besides putting width attributes on the div, can you style the table with width:95%; to force wrapping inside the table when the type doesn't fit?

Captaffy

3:03 pm on Aug 6, 2002 (gmt 0)

10+ Year Member



Besides putting width attributes on the div, can you style the table with width:95%; to force wrapping inside the table when the type doesn't fit?

If the user has large text, the table still has to increase in size to fit.
The real problem I guess is that one column is made up of e-mail addresses - some of which are very long, and don't wrap.

moonbiter

4:39 pm on Aug 6, 2002 (gmt 0)

10+ Year Member



The real problem is a combination of current browser support for CSS 2 and the way they interpret the visual formatting model [w3.org].

This issue is one of overflow, which is handled in the visual effects section [w3.org] of the CSS 2 specification. Unfortunately, support for CSS2 is spotty at best, even in the most compliant and standards-supporting of browsers.

Even if browser support for overflow were perfect, one would still have issues with this because the recommendation leaves the definition of the initial containing block up to the browsers and this has implications on, for instance, how to decide what the default width of a div should be.

The developers of Opera and Mozilla seem to have decided to make the width of the initial containing block the width of the viewport, and any large child elements should just overflow. The developers of Internet Explorer, on the other hand, seem to have decided that the width of the initial containing block should be as wide as the widest rendered element in the document.

So I don't think there is a good answer to this one.