FFFF csswg-drafts/css-overflow/Overview.src.html at 6c62b0ca81bc8dbbf0917d9d448a7222439406fd · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
1256 lines (1110 loc) · 40.7 KB

File metadata and controls

1256 lines (1110 loc) · 40.7 KB
split within another type of fragmentation context?
These rules prevent ever using ''::nth-fragment()'' for that,
despite that the name seems the most logical name for such a feature.
</p>
<div class="example">
<table class="source-demo-pair"><tr><td><pre>&lt;!DOCTYPE HTML&gt;
&lt;title&gt;Breaking content into
equal-sized cards&lt;/title&gt;
&lt;style&gt;
.in-cards {
overflow: fragments;
width: 13em;
height: 8em;
padding: 4px;
border: medium solid blue;
margin: 6px;
font: medium/1.3 Times New
Roman, Times, serif;
}
&lt;/style&gt;
&lt;div class="in-cards"&gt;
In this example, the text in the div
is broken into a series of cards.
These cards all have the same style.
The presence of enough content to
overflow one of the cards causes
another one to be created. The second
card is created just like it's the
next sibling of the first.
&lt;/div&gt;</pre></td><td>
<div class="in-cards-demo">In this example, the text in the<br>div is broken into a series of<br>cards. These cards all have the<br>same style. The presence of<br>enough content to overflow<br>one of the cards causes another</div>
<div class="in-cards-demo">one to be created. The second<br>card is created just like it's the<br>next sibling of the first.</div>
</td></tr></table>
</div>
<p class="issue">
We should specify that ''overflow: fragments'' does not apply
to at least some table parts,
and perhaps other elements as well.
We need to determine exactly which ones.
</p>
<p class="issue">
This specification needs to say which type of
fragmentation context is created
so that it's clear which values of the 'break' property
cause breaks within this context.
We probably want ''break: regions'' to apply.
</p>
<p class="issue">
This specification needs a processing model
that will apply in cases where the layout containing the
fragments has characteristics that use the intrinsic size of the fragments
to change the amount of space available for them,
such as [[CSS3-GRID-LAYOUT]].
There has already been some work on such a processing model
in [[CSS3-REGIONS]],
and the work done on a model there,
and the editors of that specification,
should inform what happens in this specification.
</p>
<h3 id="fragment-styling">Fragment styling</h3>
<h4 id="fragment-pseudo-element">The ::nth-fragment() pseudo-element</h4>
<p>
The ::nth-fragment() pseudo-element is a pseudo-element
that describes some of the <i>fragment box</i>es generated by an element.
The argument to the pseudo-element takes the same syntax
as the argument to the :nth-child() pseudo-class
defined in [[!SELECT]], and has the same meaning
except that the number is relative to
<i>fragment box</i>es generated by the element
instead of siblings of the element.
</p>
<p class="note">
Selectors that allow addressing fragments
by counting from the end rather than the start
are intentionally not provided.
Such selectors would interfere with determining
the number of fragments.
</p>
<p class="issue">
Depending on future discussions,
this ''::nth-fragment(<var>an+b</var>)'' syntax
may be replaced with
the new ''::fragment:nth(<var>an+b</var>)'' syntax.
</p>
<h4 id="style-of-fragments">Styling of fragments</h4>
<p class="issue">
Should this apply to fragment overflow only,
or also to paginated overflow?
(If it applies,
then stricter property restrictions would be needed
for paginated overflow.)
</p>
<p>
In the absence of rules with ''::nth-fragment()'' pseudo-elements,
the computed style for each <i>fragment box</i>
is the computed style for the element
for which the <i>fragment box</i> was created.
However, the style for a <i>fragment box</i> is also influenced
by rules whose selector's <i>subject</i> [[!SELECT]]
has an ''::nth-fragment()'' pseudo-element,
if the 1-based number of the <i>fragment box</i> matches
that ''::nth-fragment()'' pseudo-element
and the selector (excluding the ''::nth-fragment()'' pseudo-element)
matches the element generating the fragments.
</p>
<p>
When determining the style of the <i>fragment box</i>,
these rules that match the fragment pseudo-element
cascade together with the rules that match the element,
with the fragment pseudo-element adding the specificity
of a pseudo-class to the specificity calculation.
<span class="issue">Does this need to be specified in
the cascading module as well?</span>
</p>
<div class="example">
<table class="source-demo-pair"><tr><td><pre>&lt;!DOCTYPE HTML&gt;
&lt;style&gt;
.bouncy-columns {
overflow: fragments;
width: 6em;
height: 10em;
float: left;
margin: 1em;
font: medium/1.25 Times New
Roman, Times, serif;
}
.bouncy-columns::nth-fragment(1) {
background: aqua; color: black;
transform: rotate(-3deg);
}
.bouncy-columns::nth-fragment(2) {
background: yellow; color: black;
transform: rotate(3deg);
}
&lt;/style&gt;
&lt;div class="bouncy-columns"&gt;
<i>...</i>
&lt;/div&gt;</pre></td><td>
<div class="bouncy-columns-demo one">In this<br>example, the<br>text in the div<br>is broken into<br>a series of<br>columns. The<br>author<br>probably</div>
<div class="bouncy-columns-demo two">intended the<br>text to fill two<br>columns. But<br>if it happens to<br>fill three<br>columns, the<br>third column is<br>still created. It</div>
<div class="bouncy-columns-demo">just doesn't<br>have any<br>fragment-specific<br>styling because<br>the author<br>didn't give it<br>any.</div>
</td></tr></table>
</div>
<p>
Styling an ''::nth-fragment()'' pseudo-element with the 'overflow'
property does take effect;
if a <i>fragment box</i> has a
computed value of 'overflow' other than ''fragments''
then that fragment box is the last fragment.
However, overriding ''overflow'' on the first fragment
does not cause the <i>fragment box</i> not to exist;
whether there are fragment boxes at all is determined by
the computed value of overflow for the element.
<span class="issue">Need to reword this to refer to the
appropriate choice of ''overflow-x'' or ''overflow-y'',
and then point to rule about the handling of the other one
of ''overflow-x'' or ''overflow-y''.</span>
</p>
<p>
Styling an ''::nth-fragment()'' pseudo-element with the 'content'
property has no effect;
the computed value of 'content' for the fragment box
remains the same as the computed value of content for the element.
</p>
<p>
Specifying ''display: none'' for a <i>fragment box</i> causes
the fragment box with that index not to be generated.
However, in terms of the indices
used for matching ''::nth-fragment()'' pseudo-elements
of later fragment boxes,
it still counts as though it was generated.
However, since it is not generated, it does not contain any content.
</p>
<p>
Specifying other values of 'display', 'position',
or 'float' is permitted, but is not allowed to change
the computed value of 'display-inside'.
(Since 'overflow', 'overflow-x', and 'overflow-y' only
apply to block containers, flex containers, and grid containers
the computed value of 'display-inside' is always
''block'', ''flex'' or ''grid''.
<span class="issue">Need to specify exactly how this works,
but it depends on
having 'display-inside' and 'display-outside' specified.</span>
< 348C /p>
<p>
To match the model for other pseudo-elements
where the pseudo-elements live inside their corresponding element,
declarations in ''::nth-fragment()'' pseudo-elements override
declarations in rules without the pseudo-element.
The relative priority within such declarations is determined
by normal cascading order (see [[!CSS21]]).
</p>
<p>
Styles specified on ''::nth-fragment()'' pseudo-elements
do affect inheritance to content within the <i>fragment box</i>.
In other words, the content within the <i>fragment box</i> must
inherit from the fragment box's style (i.e., the pseudo-element style)
rather than directly from the element.
This means that elements split between fragment boxes may
have different styles for different parts of the element.
</p>
<p class="issue">
This inheritance rule allows specifying styles indirectly
(by using explicit ''inherit'' or using default inheritance
on properties that don't apply to '':first-letter'')
that can't be specified directly
(based on the rules in the next section).
This is a problem.
The restrictions that apply to styling inside fragments
should also apply to inheritance from fragments.
</p>
<div class="example">
<table class="source-demo-pair"><tr><td><pre>&lt;!DOCTYPE HTML&gt;
&lt;style&gt;
.article {
overflow: fragments;
}
.article::nth-fragment(1) {
font-size: 1.5em;
margin-bottom: 1em;
height: 4em;
}
.article::nth-fragment(2) {
margin-left: 5em;
margin-right: 2em;
}
&lt;/style&gt;
&lt;div class="article"&gt;
The &lt;code&gt;font-size&lt;/code&gt; property<i>...</i>
&lt;/div&gt;</pre></td><td>
<div class="article-font-inherit-demo one">The <code>font-size</code> property<br>specified on the fragment<b 8026 r>is inherited into the</div>
<div class="article-font-inherit-demo two">descendants of the fragment.<br>This means that inherited<br>properties can be used<br>reliably on a fragment, as in<br>this example.</div>
</td></tr></table>
</div>
<h4 id="style-in-fragments">Styling inside fragments</h4>
<p class="issue">
Should this apply to fragment overflow only,
or also to paginated overflow,
or even to pagination across pages?
</p>
<p>
The ''::nth-fragment()'' pseudo-element
can also be used to style
content inside of a <i>fragment box</i>.
Unlike the ''::first-line'' and ''::first-letter'' pseudo-elements,
the ''::nth-fragment()'' pseudo-element can be applied
to parts of the selector other than the subject:
in particular, it can match ancestors of the subject.
However, the only CSS properties applied
by rules with such selectors
are those that apply
to the ''::first-letter'' pseudo-element.
</p>
<p>
To be more precise,
when a rule's selector has ''::nth-fragment()'' pseudo-elements
attached to parts of the selector other than the subject,
the declarations in that rule apply to
a fragment (or pseudo-element thereof) when:
</p>
<ol>
<li>
the declarations are for properties that apply to the
''::first-letter'' pseudo-element,
</li>
<li>
the declarations would apply to
that fragment (or pseudo-element thereof)
had those ''::nth-fragment()'' pseudo-elements been removed,
with a particular association between
each sequence of simple selectors and the element it matched,
and
</li>
<li>
for each removed ''::nth-fragment()'' pseudo-element,
the fragment lives within a <i>fragment box</i>
of the element associated in that association
with the selector that the pseudo-element was attached to,
and whose index matches the pseudo-element.
</li>
</ol>
<div class="example">
<table class="source-demo-pair"><tr><td><pre>&lt;!DOCTYPE HTML&gt;
&lt;style&gt;
.dark-columns {
overflow: fragments;
width: 6em;
height: 10em;
float: left;
margin-right: 1em;
font: medium/1.25 Times New
Roman, Times, serif;
}
.dark-columns::nth-fragment(1) {
background: aqua; color: black;
}
.dark-columns::nth-fragment(1) :link {
color: blue;
}
.dark-columns::nth-fragment(1) :visited {
color: purple;
}
.dark-columns::nth-fragment(2) {
background: navy; color: white;
}
.dark-columns::nth-fragment(2) :link {
color: aqua;
}
.dark-columns::nth-fragment(2) :visited {
color: fuchsia;
}
&lt;/style&gt;
&lt;div class="dark-columns"&gt;
<i>...</i>
&lt;/div&gt;</pre></td><td>
<div class="dark-columns-demo one">In this<br><a href="http://en.wiktionary.org/wiki/example">example</a>, the<br>text flows<br>from one<br>light-colored<br>fragment into<br>another<br>dark-colored</div>
<div class="dark-columns-demo two">fragment. We<br>therefore want<br>different styles<br>for <a href="http://www.w3.org/Provider/Style/IntoContext.html">hyperlinks</a><br>in the different<br>fragments.</div>
</td></tr></table>
</div>
<h3 id="max-lines">The 'max-lines' property</h3>
<p>
Authors may wish to style the opening lines of an element
with different styles
by putting those opening lines in a separate fragment.
However, since it may be difficult to predict the exact height
occupied by those lines
in order to restrict the first fragment to that height,
this specification introduces a 'max-lines' property
that forces a fragment to break
after a specified number of lines.
This forces a break after the given number of lines
contained within the element or its descendants,
as long as those lines are in the same block formatting context.
</p>
<table class=propdef>
<tr>
<th>Name:
<td><dfn>max-lines</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>none | &lt;integer&gt;
<tr>
<th>Initial:
<td>none
<tr>
<th>Applies to:
<td>fragment boxes
<tr>
<th>Inherited:
<td>no
<tr>
<th>Animatable:
<td>as <a href="http://www.w3.org/TR/css3-transitions/#animatable-types">integer</a>
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed&nbsp;value:
<td>specified value
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per grammar</abbr>
</table>
<dl>
<dt>none
<dd>
<p>
Breaks occur only as specified elsewhere.
</p>
</dd>
<dt>&lt;integer&gt;
<dd>
<p>
In addition to any breaks specified elsewhere,
a break is forced before any line that would exceed
the given number of lines
being placed inside the element
(excluding lines that are in
a different block formatting context from
the block formatting context to which
an unstyled child of the element would belong).
</p>
<p class="issue">
If there are multiple boundaries between this line
and the previous, where exactly (in terms of element
boundaries) is the break forced?
</p>
<p>
Only positive integers are accepted.
Zero or negative integers are a parse error.
</p>
</dd>
</dl>
<p class="issue">Should this apply to fragment overflow only, or also
to pagination?</p>
<div class="example">
<table class="source-demo-pair"><tr><td><pre>&lt;!DOCTYPE HTML&gt;
&lt;style&gt;
.article {
overflow: fragments;
}
.article::first-letter {
font-size: 2em;
line-height: 0.9;
}
.article::nth-fragment(1) {
font-size: 1.5em;
max-lines: 3;
}
.article::nth-fragment(2) {
column-count: 2;
}
&lt;/style&gt;
&lt;div class="article"&gt;
<i>...</i>
&lt;/div&gt;</pre></td><td>
<div class="article-max-lines-demo one">The max-lines property allows<br>authors to use a larger font for the first<br>few lines of an article. Without the</div>
<div class="article-max-lines-demo two">max-lines property, authors<br>might have to use the<br>'height' property instead, but<br>that would leave a slight gap<br>if the author miscalculated<br>how much height a given<br>number of lines would<br>occupy (which might be</div>
<div class="article-max-lines-demo three">particularly hard if the author<br>didn't know what text would<br>be filling the space, exactly<br>what font would be used, or<br>exactly which platform's font<br>rendering would be used to<br>display the font).</div>
</td></tr></table>
</div>
<h2 id="static-media">Overflow in static media</h2>
<p class="issue">
This specification should define useful behavior
for all values of 'overflow'
in static media (such as print).
Current implementation behavior is quite poor and
produces unexpected results when authors have not considered
what will happen when
the content they produce for interactive media
is printed.
</p>
<h2 id="conformance">
Conformance</h2>
<h3 id="placement">
Module interactions</h3>
<p>This module extends the 'overflow'
feature defined in [[CSS21]] section 11.1.1. It defines additional
overflow handling mechanisms that implementations must implement as
described in this module in order to conform to this module.</p>
<p>No properties in this module apply to the <code>::first-line</code> or