|
Convenient web based access to our favorite web design Usenet groups
|
 |
This is Interesting: Free Magazines for Graphics designers and webmasters
| Author |
| Thread |
 |
|
|
|
|
|
 |
 |
 |
Best hack for floats not included in height |
 |
|
 |
|
|
|
  09-13-05 - 04:19 AM
|
Here's the problem:
http://pages.prodigy.net/chris_beal...theproblem.html
The page contains inline text, then some additional pairs of text which
are floated right and left. (This is a transcript of a historical legal
document with signatures on the right and witnesses on the left). The
'document' ends with no additional inline text. The background of the
entire document should be brown inside a white body, (in this test the
body is inside a green HTML structure) but it isn't (the actual
appearance depends greatly on what browser you are using), largely
because the height of the floated boxes is not included in the height of
the 'document' box within which they are contained, per CSS2, Section
10.6.3, which states, regarding the height of a box, "If it has
block-level children, it is the distance from the top border-edge of the
topmost block-level child box, to the bottom border-edge of the
bottommost block-level child box. Only children in the normal flow are
taken into account (i.e., floating boxes and absolutely positioned boxes
are ignored,..."
Thus floating boxes do not extend the height of their containing block.
That's bad when they are part of the same logical structure and you
want them to inherit their parent's color.
I've forced background-color: inherit here, but I'd much rather be able
to use the default background-color: transparent.
Here's the workaround:
http://pages.prodigy.net/chris_beal...workaround.html
I've added:
<p style="clear: both">
</p>
below the floated blocks. This extends the height of the containing
block to include them.
And now I can leave the backgrounds transparent:
http://pages.prodigy.net/chris_beal...ransparent.html
The question (you knew there was going to be one, right?).
Is this ugly hack to the HTML the best way to resolve this issue with
CSS styling?
If you'd like to see one of these documents in its native environment
(without any background colors), look at
http://beallsprings.org/WC.Deed%20GG.114-15.T.html.
Thanks,
Chris Beall
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
|
|
 |
|
|
 |
 |
Re: Best hack for floats not included in height |
 |
|
 |
|
|
|
  09-14-05 - 12:46 AM
|
Chris Beall wrote:
> Gus Richter wrote:
>
>
>
> Gus,
>
> OK. Seems a hack to me because you have to add HTML which is not
> semantically part of the data in order to have something to style with
> the clear: both.
The only time that I would call it an unnecessary hack, IMHO, is if
there were subsequent content and the clear were applied this way and
not applied to the subsequent element.
For example, you have used a "P Clear" whereas some people use a "DIV
Clear" as a norm, instead of applying the Clear directly to the
subsequent element. This, I believe, to be due to lack of understanding,
although I also believe that in some instances, for which I cannot think
of an example at the moment other than yours, it may be the only
solution. Additionally, such use of a Clear may create extra
difficulties with margins collapsing.
--
Gus
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
 |
Re: Best hack for floats not included in height |
 |
|
 |
|
|
|
  09-15-05 - 04:21 AM
|
Gus Richter wrote:
> Chris Beall wrote:
>
>
>
> The only time that I would call it an unnecessary hack, IMHO, is if
> there were subsequent content and the clear were applied this way and
> not applied to the subsequent element.
>
> For example, you have used a "P Clear" whereas some people use a "DIV
> Clear" as a norm, instead of applying the Clear directly to the
> subsequent element. This, I believe, to be due to lack of understanding,
> although I also believe that in some instances, for which I cannot think
> of an example at the moment other than yours, it may be the only
> solution. Additionally, such use of a Clear may create extra
> difficulties with margins collapsing.
>
Gus,
Hmmm. Why didn't I use a <div>? Seems more natural to me now. Back to
the sandbox...
Chris Beall
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
 |
Re: Best hack for floats not included in height |
 |
|
 |
|
|
|
  09-15-05 - 09:26 AM
|
Gus Richter wrote:
> Chris Beall wrote:
>
>
>
> The only time that I would call it an unnecessary hack, IMHO, is if
> there were subsequent content and the clear were applied this way and
> not applied to the subsequent element.
>
> For example, you have used a "P Clear" whereas some people use a "DIV
> Clear" as a norm, instead of applying the Clear directly to the
> subsequent element. This, I believe, to be due to lack of understanding,
> although I also believe that in some instances, for which I cannot think
> of an example at the moment other than yours, it may be the only
> solution. Additionally, such use of a Clear may create extra
> difficulties with margins collapsing.
>
Gus,
OK, I tried <div>, but it didn't work so I reverted to <p>. In my case
the containing block ended with two floats, one to the left and one to
the right. The container was, in turn, followed by more inline text.
With an empty <div> the following inline text slipped up into the space
between the floats (IE) and the background within the original container
was not extended low enough by a hair (IE) or several lines (NN 7.1).
I'll be happy until I hear from some other browser user that it makes a
mess in their environment.
Chris Beall
|
|
|
| [
Post Follow-Up to this message ]
|
|
|
|
|
 |
 |
Re: Best hack for floats not included in height |
 |
|
 |
|
|
|
 |
| All times are GMT. The time now is 07:47 AM. |
 |
|
|
|
|
|  |
|