8000 csswg-drafts/css-shapes-2/Overview.bs at 8420964ed639efcb1e7e33714dba8269c69c81b0 · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
477 lines (400 loc) · 13.4 KB

File metadata and controls

477 lines (400 loc) · 13.4 KB
<h1>CSS Shapes Module Level 2</h1>
<pre class='metadata'>
Status: ED
Work Status: Exploring
Shortname: css-shapes
Level: 2
Group: csswg
TR: http://www.w3.org/TR/css-shapes-2/
ED: http://dev.w3.org/csswg/css-shapes-2/
Editor: Rossen Atanassov, Microsoft Corporation, ratan@microsoft.com
Editor: Alan Stearns, Adobe Systems&#44; Inc., stearns@adobe.com
!Issues list: <a href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&amp;product=CSS&amp;component=Shapes&amp;resolution=---&amp;cmdtype=doit">In Bugzilla</a>
Abstract: This draft contains the features of CSS relating to wrapping content around and inside shapes. It (implicitly for now) includes and extends the functionality of CSS Shapes Level 1 [[CSS-SHAPES]]. The main points of extension compared to level 1 include additional ways of defining shapes, defining an exclusion area using a shape, and restricting an element's content area using a shape.
Link Defaults: css21 (property) margin, css-display-3 (value) table
</pre>
<style type="text/css">
.singleImgExample {
display: block;
margin: auto;
}
.example-table {
table-layout: fixed;
width: 100%;
}
.example-table tr td img {
width: 90%;
}
</style>
<h2 id="intro">
Introduction</h2>
<em>This section is not normative.</em>
Level 1 of this specification
defined properties to control
the geometry of an element's
<span>float area</span>.
This level defines how shapes apply to exclusions.
It also includes a 'shape-inside' property
for applying a shape
to an element's content area.
And finally it defines new ways
of specifying shapes for all
of these applications.
<h2 id="terminology">
Terminology</h2>
<dfn>Exclusion area</dfn>
The area used for excluding
inline flow content
around an exclusion box.
The <span>exclusion area</span>
is equivalent to the
<a href="http://www.w3.org/TR/CSS2/box.html#box-dimensions">border box</a>
for an exclusion box.
This specification's 'shape-outside' property
can be used to define arbitrary,
non-rectangular <span>exclusion areas</span>.
The 'shape-inside' property also defines
an <span>exclusion area</span>,
but in this case it is the area outside the shape
that inline content avoids.
<dfn>Float area</dfn>
The area used for wrapping content
around a float element.
By default,
the float area is
the float element's
<a href="http://www.w3.org/TR/CSS2/box.html#box-dimensions">margin box</a>.
This specification's 'shape-outside' property
can be used to define arbitrary,
non-rectangular float areas.
<dfn>Content area</dfn>
The <a href="http://www.w3.org/TR/CSS2/box.html#box-dimensions">content area</a>
is normally used for layout of the inline flow content of a box.
<div class="issue-marker" data-bug_id="15089" data-bug_status="NEW">
<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=15089">Issue-15089</a>
<div class="issue-details">
<p class="short-desc">shrink-to-fit circle / shape</p>
</div>
</div>
<h2 id="shapes">
Shapes</h2>
Shapes define arbitrary geometric contours
around which inline content flows.
The shape-outside property defines
the <span>float area</span> for a float,
and the exclusion area for an exclusion.
<h2 id="basic-shape-functions">
Basic Shapes</h3>
Add the final
<a href="http://www.w3.org/TR/css-shapes/#basic-shape-functions">level 1</a>
section.
<h3 id="supported-basic-shapes">
Supported Shapes</h3>
Add the final
<a href="http://www.w3.org/TR/css-shapes/#basic-shape-functions">level 1</a>
section, with the following integrated.
<dl>
<dt><dfn>path()</dfn> =
path( [<<fill-rule>>,]? <<string>> )
</dt>
<dd>
<ul>
<li>
<dfn><<fill-rule>></dfn> -
The filling rule used
to determine the interior
of the path.
See <a href="http://www.w3.org/TR/SVG/painting.html#FillRuleProperty">fill-rule</a> property
in SVG for details.
Possible values are ''nonzero''
or ''evenodd''.
Default value when omitted is ''nonzero''.</li>
<li>
The <string> represents an
<a href="http://www.w3.org/TR/SVG11/paths.html#PathData">SVG Path data string</a>.
The path data string must be conform
to the grammar and parsing rules of SVG 1.1.
The initial position is defined
by the first “move to” argument
in the path string.
For the initial direction follow SVG 1.1.
</li>
</ul>
</dd>
</dl>
<div class="issue-marker wrapper">
<div class="issue-marker" data-bug_id="16448" data-bug_status="ASSIGNED">
<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=16448">Issue-16448</a>
<div class="issue-details">
<p class="short-desc">Should we revisit the decision to not allow SVG path syntax in the shape-inside, shape-outside properties</p>
</div>
</div>
</div>
<h2 id='referencing-svg-shapes'>
Referencing SVG shapes</h4>
An SVG shape can be referenced using the <code>url()</code> syntax.
The shape can be any
of the <a href="http://www.w3.org/TR/SVG/shapes.html">SVG basic shapes</a>
or a <a href="http://www.w3.org/TR/SVG/paths.html">path element</a>.
<div class="example">
<div style="float:right">
<img alt="results of referencing SVG shapes" src="images/svg-shape-reference.png">
</div>
<code class="html"><pre>
&lt;style&gt;
div {
height: 400px;
width: 400px;
}
.in-a-circle {
shape-outside: url(#circle_shape);
}
.in-a-path {
shape-outside: url(#path-shape);
}
&lt;/style&gt;
&lt;svg ...&gt;
&lt;circle id="circle_shape" cx="50%" cy="50%" r="50%" /&gt;
&lt;path id="path-shape" d="M 100 100 L 300 100 L 200 300 z" /&gt;
&lt;/svg&gt;
&lt;div class="around-a-circle"&gt;...&lt;/div&gt;
&lt;div class="around-a-path"&gt;...&lt;/div&gt;
</pre></code>
</div>
<h2 id="shapes-from-image">
Shapes from Image</h3>
Add the final
<a href="http://www.w3.org/TR/css-shapes/#shapes-from-image">level 1</a>
section.
Issue: One <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=16716">suggestion</a>
is to define a shape based on an element's rendered content.
This could have security implications.
Issue: Another <a href="http://lists.w3.org/Archives/Public/www-style/2014Mar/0120.html">suggestion</a>
is to add something to an image() function
that determines the relevant pixels to use
(both for defining a shape and for display).
<h2 id="shapes-from-box-values">
Shapes from Box Values</h2>
Add the final
<a href="http://www.w3.org/TR/css-shapes/#shapes-from-box-values">level 1</a>
section.
<h2 id="declaring-shapes">
Declaring Shapes</h3>
A shape can be declared with
the 'shape-outside' property,
with possible modifications
from the 'shape-margin' property.
The shape defined by
the 'shape-outside'
and 'shape-margin' properties
changes the geometry
of a float element's
<span>float area</span>
and an exclusion element's
<span>exclusion area</span>.
A shape can be declared with
the 'shape-inside' property,
with possible modifications
from the 'shape-padding' property.
The shape defined by
the 'shape-inside'
and 'shape-padding' properties
defines an <span>exclusion area</span>
that contributes
to the element's <span>wrapping context</span>.
The 'shape-inside' property applies
to all block-level elements.
<div class="example">
The red box illustrates
an exclusion element's content box,
which is unmodified and subject
to normal CSS positioning
(here absolute positioning).
<pre><code class="html">
&lt;style type="text/css"&gt;
.exclusion {
wrap-flow: both;
position: absolute;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
shape-outside: circle(50% at 50% 50%);
border: 1px solid red;
}
&lt;/style&gt;
&lt;div style=”position: relative;”&gt;
&lt;div class=”exclusion”&gt;&lt;/div&gt;
Lorem ipsum dolor sit amet...
&lt;/div&gt;
</code></pre>
<img class="singleImgExample"
src="images/shapes_CSS2.1_MBP.png"
alt="Example rendering of circle shape and box model."
style="max-width:40%"/>
</div>
<h3 id="shape-outside-property">
The 'shape-outside' Property</h4>
Add the final
<a href="http://www.w3.org/TR/css-shapes/#shape-outside-property">level 1</a>
section with the change that
shape-outside applies
to block-level elements
and has an effect
if the element
is an exclusion.
<h3 id="shape-inside-property">
The 'shape-inside' Property</h4>
The 'shape-inside' property adds
one or more exclusion areas
to the element's wrapping context.
This modifies the normal rectangular shape
of the content area
to a possibly non-rectangular wrapping area.
The exclusion areas
are defined by subtracting the shape
from the element's content area.
Any part of the shape outside
the element's content area
has no effect.
<pre class='propdef'>
Name: shape-inside
Value: auto | outside-shape | [ <<basic-shape>> || shape-box ] | <<image>> | display
Initial: auto
Applies To: block-level elements
Inherited: no
Computed Value: computed lengths for <<basic-shape>>, the absolute URI for <<uri>>, otherwise as specified</td>
Media: visual
Animatable: as specified for <<basic-shape>>, otherwise no
</pre>
The values of this property have the following meanings:
<dl>
<dt><dfn for=shape-inside>''auto''</dfn></dt>
<dd>
The shape is computed based on the content box of the element.
</dd>
</dl>
<dl>
<dt><dfn for=shape-inside>''outside-shape''</dfn></dt>
<dd>
The shape is computed based on
the shape defined by the shape-outside
and shape-margin properties.
</dd>
</dl>
<dl>
<dt><dfn>&lt;basic-shape&gt;</dfn></dt>
<dd>
The shape is computed based
on the values of one of
''inset()'', ''circle()'', ''ellipse()'' or ''polygon()''.
</dd>
</dl>
<dl>
<dt><dfn>&lt;uri&gt;</dfn></dt>
<dd>
If the &lt;uri&gt; references an SVG shape element,
that element defines the shape.
Otherwise, if the &lt;uri&gt; references an image,
the shape is extracted and computed
based on the alpha channel
of the specified image.
If the &lt;uri&gt; does not reference
an SVG shape element or an image,
the effect is as if the value ''auto'' had been specified.
</dd>
</dl>
<dl>
<dt><dfn for=shape-inside>''display''</dfn></dt>
<dd>
The shape is computed based on the shape of the display
as described in <a href="https://drafts.csswg.org/css-round-display">css-round-display</a>.
</dd>
</dl>
The 'shape-inside' property applies to floats.
The 'shape-inside' property may not apply on some elements
such as elements with a computed 'display' value of ''display/table''.
<div class='figure'>
<img alt="Content flowing with and without a shape-inside"
src="images/shape-inside-content.png"/>
<p class="caption">Effect of shape-inside on inline content.</p>
</div>
Overflow content avoids
the exclusion area(s) added
by 'shape-inside' and 'shape-padding'
(as well as any other exclusion areas
in the element's wrapping context).
In other words,
overflow continues outside
the rectangular bounds of the element.</p>
<div class='figure'>
<img alt="Overflow interacting with rounded rect"
style="display:inline-block;vertical-align:top"
src="images/rounded-rect-overflow.png"/>
<img alt="Overflow interacting with ellipse"
style="display:inline-block;vertical-align:top"
src="images/ellipse-overflow.png"/>
<p class="caption">
Overflow interacting with exclusion areas defined
by 'shape-inside' and 'shape-padding'.
</p>
</div>
Issue: improve the illustration above,
using text to show overflow instead of greeked boxes.
When a shape-inside has a definite size
(no percentages used in the shape's definition)
an auto-sized element should use the shape
as a constraint in determining its maximum size.
<h3 id="shape-image-threshold-property">
The shape-image-threshold Property</h4>
Add the final
<a href="http://www.w3.org/TR/css-shapes/#shape-image-threshold-property">level 1</a>
section with the change that
it applies to both <span>shape-inside</span>
and <span>shape-outside</span>.
<h3 id="shape-image-source-type-property">
The shape-image-source-type Property</h4>
Should we add an alpha/luminance switch
to determine which values we use
from the shape-image source?
This could just be a keyword
on the shape-image-threshold property.
Whatever we go with should be compatible
with the alpha/luminance switch from mask sources.
<h3 id="shape-margin-property">
The 'shape-margin' property</h4>
Add the final
<a href="http://www.w3.org/TR/css-shapes/#shape-margin-property">level 1</a>
section with the change that it applies to exclusions.
<h3 id="shape-padding-property">
The 'shape-padding' Property</h4>
The 'shape-padding' property adds padding to a shape-inside.
This defines a new shape where every point
is the specified distance from the shape-inside.
This property takes on positive values only.
<pre class='propdef'>
Name: shape-padding
Value: <<length>>
Initial: none
Applies To: block-level elements
Inherited: no
Computed Value: the absolute length
Media: visual
Animatable: as <a href="http://www.w3.org/TR/css3-transitions/#animtype-lpcalc">length, percentage, or calc</a>
</pre>
<div class="example">
<p>A 'shape-padding' creating an offset
from a circlular shape-inside.
The light blue rectangles represent
inline content affected
by the shape created
by the padding.</p>
<img src="images/shape-padding.png"
alt="Example of a shape-padding offset"/>
</div>
Note: The 'shape-padding' property
only affects layout of content
inside the element it applies to
while the 'shape-margin' property
only affects layout of content
outside the element.