Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > css problem (float)

Reply
Thread Tools

css problem (float)

 
 
Deephay
Guest
Posts: n/a
 
      09-05-2007
Greetings all,

I am currently writting a 3-column full-width webpage, I have a layout
problem, here is demo of the page:

<html>
<body>
<div style="float: left; width: 25%; border-right: 1px
dashed; min-height: 20em; padding: 1em"><p>test testtest test test
test test test test test test test test test test test test test test
test test test test test test test test test test test test test test
test</p></div>
<div style="float: right; width: 25%; border-left: 1px
dashed; min-height: 20em; padding: 1em">test test test test test test
test test test test test test test test test test test test test test
test test test test test test test test test test test test test test
test test test test test test test test test test test test test test
test </div>
<div style="border: 1px solid">content content content
content content content content content content content content
content content content content content content content content
content content content content content content content content
content content content content content content content content
content content content content content content content content
content content content content content content content content
content content content content</div>
</body>
</html>

I have three columns (<div>), the width of the middle column (the last
<div>) will equal to 100% of the body width (according to CSS spec.),
but the content in that <div> will be put into the spaces between the
left and right floats according to the CSS spec, my problem is: some
times my CMS system will put a <table width="100%"><tr><td
align="center">content</td></tr>, this will break the layout of the
page because the middle column is not (100% - 2 x %25) but 100% and
the table width will be 100% either.

Specify the width of the middle column direcly in the stylesheet (45%,
say) will help, but I am not sure whether it is a good idea.

Any suggestion is very much appreciated. TIA!

Cheers,
Deephay

 
Reply With Quote
 
 
 
 
dorayme
Guest
Posts: n/a
 
      09-05-2007
In article
<. com>,
Deephay <> wrote:


> I have three columns (<div>), the width of the middle column (the last
> <div>) will equal to 100% of the body width (according to CSS spec.),
> but the content in that <div> will be put into the spaces between the
> left and right floats according to the CSS spec, my problem is: some
> times my CMS system will put a <table width="100%"><tr><td
> align="center">content</td></tr>,


Put a table where?

--
dorayme
 
Reply With Quote
 
 
 
 
Deephay
Guest
Posts: n/a
 
      09-05-2007
On Sep 5, 2:07 pm, dorayme <doraymeRidT...@optusnet.com.au> wrote:
> In article
> <1188971836.604620.282...@57g2000hsv.googlegroups. com>,
>
> Deephay <tudo...@gmail.com> wrote:
> > I have three columns (<div>), the width of the middle column (the last
> > <div>) will equal to 100% of the body width (according to CSS spec.),
> > but the content in that <div> will be put into the spaces between the
> > left and right floats according to the CSS spec, my problem is: some
> > times my CMS system will put a <table width="100%"><tr><td
> > align="center">content</td></tr>,

>
> Put a table where?

in the middle column of course.
>
> --
> dorayme



 
Reply With Quote
 
Ben C
Guest
Posts: n/a
 
      09-05-2007
On 2007-09-05, Deephay <> wrote:
> Greetings all,
>
> I am currently writting a 3-column full-width webpage, I have a layout
> problem, here is demo of the page:

[...]
> I have three columns (<div>), the width of the middle column (the last
><div>) will equal to 100% of the body width (according to CSS spec.),
> but the content in that <div> will be put into the spaces between the
> left and right floats according to the CSS spec, my problem is: some
> times my CMS system will put a <table width="100%"><tr><td
> align="center">content</td></tr>, this will break the layout of the
> page because the middle column is not (100% - 2 x %25) but 100% and
> the table width will be 100% either.
>
> Specify the width of the middle column direcly in the stylesheet (45%,
> say) will help, but I am not sure whether it is a good idea.


That sounds like not a bad idea. The problem is you've got padding and
borders so things won't add up properly.

But the general idea of giving the middle column something like width:
45%; margin-left: 25%; margin-right: 25% should do the trick from the
point of view of that stupid table.

Why not fix the CMS system?
 
Reply With Quote
 
Deephay
Guest
Posts: n/a
 
      09-05-2007
On Sep 5, 5:23 pm, Ben C <spams...@spam.eggs> wrote:
> On 2007-09-05, Deephay <tudo...@gmail.com> wrote:
>
>
>
> > Greetings all,

>
> > I am currently writting a 3-column full-width webpage, I have a layout
> > problem, here is demo of the page:

> [...]
> > I have three columns (<div>), the width of the middle column (the last
> ><div>) will equal to 100% of the body width (according to CSS spec.),
> > but the content in that <div> will be put into the spaces between the
> > left and right floats according to the CSS spec, my problem is: some
> > times my CMS system will put a <table width="100%"><tr><td
> > align="center">content</td></tr>, this will break the layout of the
> > page because the middle column is not (100% - 2 x %25) but 100% and
> > the table width will be 100% either.

>
> > Specify the width of the middle column direcly in the stylesheet (45%,
> > say) will help, but I am not sure whether it is a good idea.

>
> That sounds like not a bad idea. The problem is you've got padding and
> borders so things won't add up properly.


Thanks, I'll do it if I have no choice.
I feel CSS behaves oddly in Firefox, according to CSS spec:

"The border box of a table, a block-level replaced element, or an
element in the normal flow that establishes a new block formatting
context (such as an element with 'overflow' other than 'visible') must
not overlap any floats in the same block formatting context as the
element itself."

But why does the middle column actually overlapped with them?

>
> But the general idea of giving the middle column something like width:
> 45%; margin-left: 25%; margin-right: 25% should do the trick from the
> point of view of that stupid table.
>
> Why not fix the CMS system?



 
Reply With Quote
 
Deephay
Guest
Posts: n/a
 
      09-05-2007
On Sep 6, 12:52 am, Deephay <tudo...@gmail.com> wrote:
> On Sep 5, 5:23 pm, Ben C <spams...@spam.eggs> wrote:
>
>
>
> > On 2007-09-05, Deephay <tudo...@gmail.com> wrote:

>
> > > Greetings all,

>
> > > I am currently writting a 3-column full-width webpage, I have a layout
> > > problem, here is demo of the page:

> > [...]
> > > I have three columns (<div>), the width of the middle column (the last
> > ><div>) will equal to 100% of the body width (according to CSS spec.),
> > > but the content in that <div> will be put into the spaces between the
> > > left and right floats according to the CSS spec, my problem is: some
> > > times my CMS system will put a <table width="100%"><tr><td
> > > align="center">content</td></tr>, this will break the layout of the
> > > page because the middle column is not (100% - 2 x %25) but 100% and
> > > the table width will be 100% either.

>
> > > Specify the width of the middle column direcly in the stylesheet (45%,
> > > say) will help, but I am not sure whether it is a good idea.

>
> > That sounds like not a bad idea. The problem is you've got padding and
> > borders so things won't add up properly.

>
> Thanks, I'll do it if I have no choice.
> I feel CSS behaves oddly in Firefox, according to CSS spec:
>
> "The border box of a table, a block-level replaced element, or an
> element in the normal flow that establishes a new block formatting
> context (such as an element with 'overflow' other than 'visible') must
> not overlap any floats in the same block formatting context as the
> element itself."
>
> But why does the middle column actually overlapped with them?
>

I have a mis-understanding, this behavior is correct.
>
>
> > But the general idea of giving the middle column something like width:
> > 45%; margin-left: 25%; margin-right: 25% should do the trick from the
> > point of view of that stupid table.

>
> > Why not fix the CMS system?



 
Reply With Quote
 
Ben C
Guest
Posts: n/a
 
      09-05-2007
On 2007-09-05, Deephay <> wrote:
> On Sep 5, 5:23 pm, Ben C <spams...@spam.eggs> wrote:

[...]
> I feel CSS behaves oddly in Firefox, according to CSS spec:
>
> "The border box of a table, a block-level replaced element, or an
> element in the normal flow that establishes a new block formatting
> context (such as an element with 'overflow' other than 'visible') must
> not overlap any floats in the same block formatting context as the
> element itself."
>
> But why does the middle column actually overlapped with them?


Because it doesn't establish a new block formatting context, it's just a
normal block-level element.

Only some block boxes start "block formatting contexts"-- floats, table
cells, positioned things, things with overflow other than visible.

You could actually use this to solve your problem, and I almost
suggested it the first time.

Note that this particular thing has only very recently been tightened up
in the CSS 2.1 spec. It used to say something like "browsers may make
block formatting context narrower when there are floats in the way".

Now it says "must" and is altogether clearer about the whole thing.

Try this, then try commenting out overflow: hidden and reloading:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title>Test Page</title>
<style type="text/css">
div
{
border: 2px solid black;
}
.left
{
float: left;
background-color: pink;
width: 25%;
height: 300px;
}
.right
{
float: right;
background-color: palegreen;
width: 25%;
height: 300px;
}
.middle
{
overflow: hidden;
background-color: blue;
height: 400px;
}

</style>
</head>
<body>
<div class="left"></div>
<div class="right"></div>
<div class="middle"></div>
</body>
</html>
 
Reply With Quote
 
Deephay
Guest
Posts: n/a
 
      09-06-2007
On Sep 6, 3:43 am, Ben C <spams...@spam.eggs> wrote:
> On 2007-09-05, Deephay <tudo...@gmail.com> wrote:
>
> > On Sep 5, 5:23 pm, Ben C <spams...@spam.eggs> wrote:

> [...]
> > I feel CSS behaves oddly in Firefox, according to CSS spec:

>
> > "The border box of a table, a block-level replaced element, or an
> > element in the normal flow that establishes a new block formatting
> > context (such as an element with 'overflow' other than 'visible') must
> > not overlap any floats in the same block formatting context as the
> > element itself."

>
> > But why does the middle column actually overlapped with them?

>
> Because it doesn't establish a new block formatting context, it's just a
> normal block-level element.
>
> Only some block boxes start "block formatting contexts"-- floats, table
> cells, positioned things, things with overflow other than visible.
>
> You could actually use this to solve your problem, and I almost
> suggested it the first time.
>
> Note that this particular thing has only very recently been tightened up
> in the CSS 2.1 spec. It used to say something like "browsers may make
> block formatting context narrower when there are floats in the way".
>
> Now it says "must" and is altogether clearer about the whole thing.
>
> Try this, then try commenting out overflow: hidden and reloading:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/REC-html40/strict.dtd">
> <html>
> <head>
> <title>Test Page</title>
> <style type="text/css">
> div
> {
> border: 2px solid black;
> }
> .left
> {
> float: left;
> background-color: pink;
> width: 25%;
> height: 300px;
> }
> .right
> {
> float: right;
> background-color: palegreen;
> width: 25%;
> height: 300px;
> }
> .middle
> {
> overflow: hidden;
> background-color: blue;
> height: 400px;
> }
>
> </style>
> </head>
> <body>
> <div class="left"></div>
> <div class="right"></div>
> <div class="middle"></div>
> </body>
> </html>


Hi Ben,

Thanks, I thought the initial value of overflow is not visible, but it
is. It is now matches my need (at least in Firefox).

Another thing:
I think Firefox does not handle CSS correctly, if you add a "width:
100%;" for the middle column, the
middle column will overlap with the right float, which is not correct
for that case since "overflow: hidden"
makes the middle column established a new block formatting context.

Cheers.

 
Reply With Quote
 
Ben C
Guest
Posts: n/a
 
      09-06-2007
On 2007-09-06, Deephay <> wrote:
> On Sep 6, 3:43 am, Ben C <spams...@spam.eggs> wrote:

[...]
>> .left
>> {
>> float: left;
>> background-color: pink;
>> width: 25%;
>> height: 300px;
>> }
>> .right
>> {
>> float: right;
>> background-color: palegreen;
>> width: 25%;
>> height: 300px;
>> }
>> .middle
>> {
>> overflow: hidden;
>> background-color: blue;
>> height: 400px;
>> }

[...]
> Another thing:
> I think Firefox does not handle CSS correctly, if you add a "width:
> 100%;" for the middle column, the middle column will overlap with the
> right float, which is not correct for that case since "overflow:
> hidden" makes the middle column established a new block formatting
> context.


You're right, it does do that, according to the spec, it is wrong. It
should move the middle one down to clear the other two in that
situation. But both Opera and Konqueror do the same thing as Firefox.

9.5:
[...]
If necessary, implementations should clear the said element by placing
it below any preceding floats, but may place it adjacent to such floats
if there is sufficient space.

But no-one actually does that.
 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Layout question - how to duplicate a table layout with CSS Eric ASP .Net 4 12-24-2004 04:54 PM
confused - html validates, css validates but validate css from the html causes errors Titus A Ducksass - AKA broken-record HTML 6 11-15-2004 12:59 PM
Set CSS property equal to another CSS property? Noozer HTML 10 10-13-2004 09:20 PM
Is there a way to set the a CSS property to be explicitly the same as another CSS property? Joshua Beall HTML 1 12-10-2003 07:21 PM
print.css and screen.css tom watson HTML 1 09-09-2003 02:48 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57