8000 csswg-drafts/css-page-floats-3/Overview.bs at 29bb0c944dfe191c89b51d0ebda57eb4fc1229d1 · xfq/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
1222 lines (933 loc) · 38.9 KB

File metadata and controls

1222 lines (933 loc) · 38.9 KB
Behave like block-start and block-end.
<dt><dfn>both</dfn>
<dd>
Behave like both-inline.
<dt><dfn>all</dfn>
<dd>
Behave like both-block and both-inline.
</dl>
<div class="example">
In this example, the two figures may appear in the same column:
<pre>
.figure { float-reference: column; float: bottom; clear: none }
&ltdiv class=figure>&lt;/div>
&ltdiv class=figure>&lt;/div>
</pre>
<img alt="sample rendering" src="images/16.png">
</div>
<div class="example">
In this example, the two figures will appear in different columns:
<pre>
.figure { float-reference: column; float: bottom; clear: bottom }
&ltdiv class=figure>&lt;/div>
&ltdiv class=figure>&lt;/div>
</pre>
<img alt="sample rendering" src="images/17.png">
</div>
<div class="example">
In this example, the two figures may appear at the bottom of the same column
due to clearing only at the top:
<pre>
.figure { float-reference: column; float: bottom; clear: top }
&l DBB6 tdiv class=figure>&lt;/div>
&ltdiv class=figure>&lt;/div>
</pre>
<img alt="sample rendering" src="images/16.png">
</div>
<div class="example">
In this example, the two figures will appear in different columns due to
clearing at the bottom:
<pre>
.figure { float-reference: column; float: bottom; clear: bottom }
&ltdiv class=figure>&lt;/div>
&ltdiv class=figure>&lt;/div>
</pre>
<img alt="sample rendering" src="images/17.png">
</div>
<div class="example">
In this example, the two figures end up the top corner of two different
pages:
<pre>
.figure { float-reference: page; float: top; clear: top }
&ltdiv class=figure>&lt;/div>
&ltdiv class=figure>&lt;/div>
</pre>
</div>
<div class="example">
In this example, the two figures request different positions, and they may
therefore end up in the same column:
<pre>
.figure.one { float-reference: column; float: top; clear: top }
.figure.two { float-reference: column; float: bottom; clear: bottom }
&ltdiv class="figure one">&lt;/div>
&ltdiv class="figure two">&lt;/div>
</pre>
</div>
<h2 id="deferring_floats">Deferring page floats</h2>
Users can influence the placement of a <a>page float</a> by deferring them to
another <a>fragmentation container</a> than where the <a>float anchor</a> is
placed.
A float that is an <a>inline float</a> cannot be deferred.
Float deferring assigns an <a>initial float reference</a>, yet float stacking
can lead page floats being moved to a subsequent <a>fragmentation container</a>
if their <a>initial float reference</a> lacks the space to host them.
The 'float-defer' property is introduced to control deferring floats:
<h3 id="float-defer-property">The 'float-defer' property</h3>
<pre class="propdef">
Name: float-defer
Value: &ltinteger> | last | none
Initial: none
Applies to: floats
Inherited: no
Percentages: N/A
Media: visual
Computed value: as specified.
Animatable: no
</pre>
This property specifies whether the <a>initial float reference</a> of a <a>page
float</a> is the <a>fragmentation container</a> in which the <a>float anchor</a>
is placed after previous page floats have been placed, or in another one.
This property is ignored if the element is an <a>inline float</a>.
Values are:
<dl>
<dt>none
<dd>The <a>initial float reference</a> is the <a>fragmentation container</a> in which the
<a>float anchor</a> is placed after all previous page floats have been placed.
<dt>&lt;integer>
<dd>
A positive integer value indicates that the <a>initial float reference</a> of
the page float should be Nth <a>fragmentation container</a> of the `fragmentation
flow`, where N is the value of the `float-defer` property plus the order
number of the <a>fragmentation container</a> in which the <a>float anchor</a> is placed
after all previous page floats have been placed within the given
<a>fragmentation context</a>. If N is larger than the order number of the last
<a>fragmentation container</a> within the given <a>fragmentation context</a> at the time of
assignment, then N is the order number of the last <a>fragmentation container</a>
within the given <a>fragmentation context</a>.
A negative integer value indicates that the <a>initial float reference</a> of
the page float should be a <a>fragmentation container</a> of the
<a>fragmentation context</a>, counting backward from the end, so that -1
is the last <a>fragmentation container</a>, -2 is the next-to-last, etc. .
In the case of a negative integer value, the <a>initial float reference</a> is the
Nth <a>fragmentation container</a> of the <a>fragmentation context</a>, where N is 1
plus the order number of the last <a>fragmentation container</a> within the given
<a>fragmentation context</a> after all previous page floats have been placed plus
the value of the `float-defer` property.
Zero is the same as `none`.
If the value of the `float-defer` property would cause the <a>initial float
reference</a> to be an inexistent <a>fragmentation container</a>, the property
is interpreted as if it were zero.
<p class="note">
Negative float-defer values put the initial float reference a certain number
to be a certain amount of fragmentation containers from the last fragmentation
container at the time of of the placement. Subsequent page float stacking
can mean that a page float is being placed in a later fragmentation container
(a page float with float-defer set to -3 can end up being placed in the
last fragmentation container), and later page floats may mean that new
fragmentation containers are added, so that the a fragmentation container
that previously was Nth last fragmentation container within a fragmentation
context now is the N+Xth last. Additional fragmentation container(s) that
are added after the page float was placed, will not cause the page float
to be moved.
<dt>last
<dd>
The <a>initial float reference</a> is the last <a>fragmentation container</a> within
the given <a>fragmentation context</a> after all previous page floats have been
placed.
</dl>
<div class="example">
Float figure to the top of the region that follows the region in which
the <a>float anchor</a> is placed:
<pre>
.figure { float-reference: region }
.figure { float: top }
.figure { float-defer: 1 }
</pre>
</div>
<div class="example">
Float figure to the top of the next-to-last column:
<pre>
.figure { float-reference: column; float: top; float-defer: -2 }
</pre>
<img alt="sample rendering" src="images/7.png">
</div>
<div class="example">
Float figure to the top of the last page:
<pre>
.figure { float-reference: page }
.figure { float: top }
.figure { float-defer: -1 }
</pre>
</div>
<div class="example">
Float figure to the top of the last column:
<pre>
.figure { float-reference: column }
.figure { float: top }
.figure { float-defer: last }
</pre>
</div>
<div class="example">
Float figure to top of the last column:
<pre>
.figure { float-reference: column; float: top; float-defer: last }
</pre>
<img alt="sample rendering" src="images/6.png">
</div>
<h2 id="wrapping-around-page-floats">Wrapping around page floats</h2>
Page floats have their 'wrap-flow' property set to 'both' initially and are
treated like exclusions. This specification does not make any further
specification about wrapping contents around page floats.
<div class="issue">
Should the 'wrap-flow' really be set to both, or should the flow be restricted
to only be on one side?
</div>
<h2 id="the-float_offset-property">The 'float-offset' property</h2>
<pre class="propdef">
Name: float-offset
Value: &lt;length> | &lt;percentage>
Initial: 0
Applies to: floats
Inherited: no
Percentages: see prose
Media: visual
Computed value: one absolute length
Animatable: no
</pre>
This property pushes a <a>page float</a> in direction opposite of the where it has been
floated with 'float'.
If the element is an <a>inline float</a>, this property is ignored.
This property can only influence a <a>page float</a> along an axis along which
it has been floated.
<dl>
<dt>&lt;percentage></dt>
<dd>
Percentage values are computed according to this formula:
<pre>
(containing-block-width - float-width) * percentage
(containing-block-height - float-height) * percentage
</pre>
</dd>
</dl>
<div class="example">
<pre>
img {
float-reference: column;
float: left;
float-offset: 2em;
}
</pre>
In this example, the image is floated to the left. Therefore, 'float-offset'
may only push the element to the right.
</div>
<div class="example">
<pre>
img {
float-reference: column;
float: right;
float-offset: 5px;
}
</pre>
<img alt="sample rendering" src="images/14.png">
</div>
<!--div class="example">
Pull quotes are often centered in a column. In this example, the pull quote is
floated to the right, and then pushed back into the center.
<img alt="sample rendering" src="images/region_pullquote.png">
<pre>
.pullquote {
float-reference: region;
float: right;
float-offset: 50%; /* 50% centers the box */
}
</pre>
</div-->
<h2 id="page-float-placement">Page float placement</h2>
The order of page floats placement is determined by the following rules:
<ol>
<li>
All page floats with 'float-reference' set to `page` are placed, in
document order, before those with 'float-reference' set to `region` and
`column`.
<li>
Thereafter, page floats with 'float-reference' set to `column` and `region`
are placed in document order.
</li>
</ol>
The placement of a single page float is a process that has to be terminated
entirely before the placement of a subsequent page float can be initiated. The
placement process consists of the following steps:
<ol>
<li>Determine the <a>initial float reference</a> by considering the
<a>fragmentation container</a> in which the <a>float anchor</a> is placed and
the `float-defer` property of the page float. The <a>float reference</a> is
initially set to be the same as the <a>initial float reference</a>.</li>
<li>Determine if the given <a>float reference</a> has enough space or can be
expanded to host the page float, if the rules of <a href="#float-stacking">
float stacking</a> and <a href="#float-reference-growth">float reference
growth</a> are to be followed. If this is not the case, and the <a>float
reference</a> is not the last <a>fragmentation container</a> within the given
<a>fragmentation context</a>, then make the following <a>fragmentation
container</a> within the given <a>fragmentation context</a> the <a>float
reference</a>. Repeat this step until the <a>float reference</a> can be
expanded enough to host the page float or it is the last <a>fragmentation
container</a> within the given <a>fragmentation context</a>.</li>
<li>If the <a>float reference</a> is the last <a>fragmentation container</a> within
the given <a>fragmentation context</a>, and it has not enough space and cannot be
expanded to host the page float, then do the following:</li>
<ol>
<li>If the <a>fragmentation context</a> allows for the addition of another
<a>fragmentation container</a> and an additional <a>fragmentation container</a>
would have the needed size to host the page float, a new <a>fragmentation
container</a> is added to the end of the <a>fragmentation context</a>. The
<a>float reference</a> is set the newly created <a>fragmentation
container</a>.</li>
<li>Otherwise, if the <a>fragmentation container</a> is a region, then the
'regionOverset` attribute of the <a>fragmentation container</a> is set to
`overset`.
</ol>
<li>The page float is placed in the <a>float reference</a> according to the rules
of 'float stacking' and 'float reference growth'.</li>
</ol>
<h3 id="float-reference-growth">Float reference growth</h3>
Float references can grow up to the their `max-height` and `max-width` or their
`available size`, whichever is the lowest, in order to accommodate page floats.
<h3 id="float-stacking">Rules for page float stacking</h3>
Page floats are stacked within a given <a>float reference</a> in the order of their
placement and in the direction of the inline- and flow-directions of the
<a>fragmentation context</a> while <a>not overlapping</a> with any other page
floats with the same <a>float reference</a> and by keeping a distance N between
the page float's margin edge and the padding edge of the <a>float reference</a>
as well as between the page float's margin edge and the margin edge of the last
previously placed page float with the same <a>float reference</a> and the same
'float' value, where N is the 'float-offset' value of the page float.
For the purpose of calculating whether enough space is available for a page floats
within the <a>float reference</a>, it is assumed that the page floats in the block
directions fill the entire line size of the <a>float reference</a> and page floats
in the inline direction fill the entire block size of the <a>float reference</a>.
For the purpose of placement, page floats in the block-start direction are also
placed at the inline-start edge of the float reference and vice versa, and page
floats in the block-end direction are placed at the inline-end edge of the float
reference and vice versa.
If the page float has a defined 'clear'-value, then the <a>float reference</a> in
which the page float is placed is closed for all subsequent page floats that
floating in the direction specified by the 'clear'-value.
<p class="issue">
We can effectively currently float to two corners: inline-start/block-start and
inline-end/block-end. We should augment this with the option to have a secondary
float direction to allow basic 2D floating.
<h2 id="relation_to_absolutely_positioned_exclusions">
Floats and absolutely positioned exclusions</h2>
Floats and absolutely positioned exclusions share some common traits, but in the
case of inline floats they are not the same. Floats that are not inline floats
should behave the same as absolutely positioned exclusions with positions and
sizes manually set to prevent overlap between floats and to prevent floats from
moving beyond the edges of the float reference, with the float reference being
grown as much as needed up to its maximum extend to accommodate all containing
floats.
<h3 id="inline_floats_and_absolutely_positioned_exclusions">
Differences between inline floats and absolutely positioned elements</h3>
<em>This section is not normative.</em>
<p>
Inline floats and absolutely positioned elements are both out-of-flow elements.
Absolutely positioned elements that are also exclusions can imitate many of
the features of floats.
<p>
However, in the case of inline floats, the block formatting context that
contains them (the <a>float containing block formatting context</a>) is
required to include the area occupied by the float, which is not a requirement
for absolutely positioned elements.
<div class="example">
An inline float inside a <a>float containing block formatting context</a> given