[csswg-drafts] How to increase margins of containers for pending floats ? (#4052)

verdy-p has just created a new issue for https://github.com/w3c/csswg-drafts:

== How to increase margins of containers for pending floats ? ==
It's impossible to define a correct left or right margin for a container, when there are conditional floats (on the left or right).

We should be able to increase the margin to take into account the maximum width and margins specified by any pending floats (as they can exist even outside the container itself).

If the computed "minimum width" of the container cannot fit in these increased margins, then it will "clear" vertically automatically after the first float (still pending on the left or right of the container, not necessarily all the same width) that leaves enough space for putting the content.

In frequent cases, (e.g. with floatting illustration images or lateral navboxes used in Wikipedia articles), it is impossible to predict where these floats will end, and
* having to specify a "clear:left/right/both" for the container is just a nuisance when the content can perfectly fit.
* we could specify a left/right margin in % or pixels to keep space available for floats, but here also it will not adapt to the situation where there's actually no floats and it will then generate undesired excessive lateral margins left completely blank.

So I suggest "margin-keep: floats/float-left/float-right" (possibly also "float-begin/float-end" to take into account Bidi and notably direction of the parent, independantly of the directionality of the container itself and of its content children).

Or alternatively:
* new values for "margin-left/right:" to make them relative (and collapsed) to the lateral margins of pending floats, like "margin-right: +10%" (or "+150px") to indicate we want a right margin to be at least 10% of the parent width (or 150px respectively), measured either from the "relative" parent content-box (in which floats may be positioned and margins are measured by default, but only when there's no such float present taking space) or otherwise from the inner lateral side of the border-box of the float (if there's at least one float taking space): this "+" indicates that behavior. In all cases, if the new computed margin  would exceeds the parent's contentbox, a vertical "clear" will occur to pass these floats.

Note as well that floats attached one side may also exceed their "relative parent" content width. and we should be able to limit their default width (unless this width is already their minimum width, in which case they will still overflow their "relative parent", which may then have to either "hide" the excess or use automatic horizontal scroll to allow seeing the float completely on a interactive output, or to render their excess on separate pages with a printed or non-interactive output with static page width).

This suggestion is independant of "margin-trim:" for the layout of content children of the container itself.


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4052 using your GitHub account

Received on Saturday, 22 June 2019 19:55:01 UTC