css problem (float)

css problem (float)

am 05.09.2007 07:57:16 von Deephay

Greetings all,

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



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


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

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




I have three columns (
), the width of the middle column (the last
) will equal to 100% of the body width (according to CSS spec.),
but the content in that
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 align="center">content, 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

Re: css problem (float)

am 05.09.2007 08:07:58 von dorayme

In article
<1188971836.604620.282350@57g2000hsv.googlegroups.com>,
Deephay wrote:


> I have three columns (

), the width of the middle column (the last
>
) will equal to 100% of the body width (according to CSS spec.),
> but the content in that
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
> align="center">content,

Put a table where?

--
dorayme

Re: css problem (float)

am 05.09.2007 10:31:22 von Deephay

On Sep 5, 2:07 pm, dorayme wrote:
> In article
> <1188971836.604620.282...@57g2000hsv.googlegroups.com>,
>
> Deephay wrote:
> > I have three columns (

), the width of the middle column (the last
> >
) will equal to 100% of the body width (according to CSS spec.),
> > but the content in that
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
> > align="center">content,
>
> Put a table where?
in the middle column of course.
>
> --
> dorayme

Re: css problem (float)

am 05.09.2007 11:23:16 von Ben C

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 (

), the width of the middle column (the last
>
) will equal to 100% of the body width (according to CSS spec.),
> but the content in that
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
> align="center">content, 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?

Re: css problem (float)

am 05.09.2007 18:52:12 von Deephay

On Sep 5, 5:23 pm, Ben C wrote:
> 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 (

), the width of the middle column (the last
> >
) will equal to 100% of the body width (according to CSS spec.),
> > but the content in that
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
> > align="center">content, 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?

Re: css problem (float)

am 05.09.2007 19:24:52 von Deephay

On Sep 6, 12:52 am, Deephay wrote:
> On Sep 5, 5:23 pm, Ben C wrote:
>
>
>
> > 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 (

), the width of the middle column (the last
> > >
) will equal to 100% of the body width (according to CSS spec.),
> > > but the content in that
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
> > > align="center">content, 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?

Re: css problem (float)

am 05.09.2007 21:43:20 von Ben C

On 2007-09-05, Deephay wrote:
> On Sep 5, 5:23 pm, Ben C 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:

"http://www.w3.org/TR/REC-html40/strict.dtd">


Test Page







Re: css problem (float)

am 06.09.2007 05:51:05 von Deephay

On Sep 6, 3:43 am, Ben C wrote:
> On 2007-09-05, Deephay wrote:
>
> > On Sep 5, 5:23 pm, Ben C 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:
>
> > "http://www.w3.org/TR/REC-html40/strict.dtd">
>
>
> Test Page
>
>
>
>


>

>

>
>

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.

Re: css problem (float)

am 06.09.2007 22:54:44 von Ben C

On 2007-09-06, Deephay wrote:
> On Sep 6, 3:43 am, Ben C 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.