8000 [css-shapes] Add examples and clarifications based on SteveZ's review · w3c/csswg-drafts@bbc6cbd · GitHub
Skip to content

Commit bbc6cbd

Browse files
committed
[css-shapes] Add examples and clarifications based on SteveZ's review
1 parent b05e48b commit bbc6cbd

6 files changed

Lines changed: 231 additions & 76 deletions

File tree

css-shapes/Overview.html

Lines changed: 85 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
rel=dcterms.rights>
1313
<meta content="CSS Shapes Module Level 1" name=dcterms.title>
1414
<meta content=text name=dcterms.type>
15-
<meta content=2013-09-10 name=dcterms.date>
15+
<meta content=2013-09-12 name=dcterms.date>
1616
<meta content="Vincent Hardy" name=dcterms.creator>
1717
<meta content="Rossen Atanassov" name=dcterms.creator>
1818
<meta content="Alan Stearns" name=dcterms.creator>
@@ -51,7 +51,7 @@
5151

5252
<h1 id=css-shapes-module>CSS Shapes Module Level 1</h1>
5353

54-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 10 September
54+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 12 September
5555
2013</h2>
5656

5757
<dl>
@@ -261,10 +261,20 @@ <h2 id=intro><span class=secno>1. </span>Introduction</h2>
261261

262262
<h2 id=definitions><span class=secno>2. </span>Definitions</h2>
263263

264+
<p><dfn id=wrap>Wrap</dfn>
265+
266+
<p> This specification uses the term ‘<a href="#wrap"><code
267+
class=property>wrap</code></a>’ to refer to flowing content around the
268+
sides of a float area. Content wraps around the right side of a
269+
left-floated box, and content wraps around the left side of a
270+
right-floated box. Line boxes next to a float are shortened as necessary
271+
to avoid intersections with the float area.
272+
264273
<p><dfn id=float-area>Float area</dfn>
265274

266-
<p> The area used for wrapping content around a float element. By default,
267-
the float area is the float element's <a
275+
<p> The area used for wrapping (or flowing) content around a float element.
276+
The rules for float behavior use the sides of the float area to determine
277+
where content flows. By default, the float area is the float element's <a
268278
href="http://www.w3.org/TR/CSS2/box.html#box-dimensions">margin box</a>.
269279
This specification's ‘<a href="#shape-outside"><code
270280
class=property>shape-outside</code></a>’ property can be used to define
@@ -348,8 +358,9 @@ <h3 id=relation-to-box-model-and-float-behavior><span class=secno>3.1.
348358

349359
<div class=example>
350360
<p> A shape with no extent will create a <a href="#float-area">float
351-
area</a> with no extent. The shape below applied to a left float will
352-
allow inline content to flow through the float's box.
361+
area</a> with no extent. Because wrapping only considers the float area,
362+
the shape below applied to a left float will allow inline content to flow
363+
through all of the float's box.
353364

354365
<p>
355366

@@ -358,11 +369,27 @@ <h3 id=relation-to-box-model-and-float-behavior><span class=secno>3.1.
358369
</code></pre>
359370
</div>
360371

372+
<div class=example>
373+
<p> A shape-outside can create open areas on both the left and right of a
374+
float area. Content still wraps only on one side of a float in this case.
375+
In the picture, the shape is rendered in blue, and the content area
376+
outside the shape in mauve.
377+
378+
<p>
379+
380+
<pre><code class=css>
381+
shape-outside: polygon(50px 0px, 100px 100px, 0px 100px);
382+
</code></pre>
383+
<img alt="Wrapping around right side of a left-float float area"
384+
class=singleImgExample src="images/float-side-example.png"></div>
385+
361386
<div class=example>
362387
<p> The following styling creates a shape much smaller than the float's
363388
content area, and adds a margin-top to the float. In the picture, the
364-
shape is rendered in blue, the content area in mauve, and the margin area
365-
in yellow. The inline content only wraps around the shape.
389+
shape is rendered in blue, the content area outside the shape in mauve,
390+
and the margin area of the float box in yellow. The inline content only
391+
wraps around the shape, and otherwise overlays the rest of the float
392+
margin box.
366393

367394
<pre><code class=html>
368395
.float-left {
@@ -376,7 +403,8 @@ <h3 id=relation-to-box-model-and-float-behavior><span class=secno>3.1.
376403
<img alt="Adding margin-top to a float with a small shape-outside"
377404
class=singleImgExample src="images/float-margin-example.png">
378405
<p> The next picture shows a possible result if two of these floats were
379-
stacked next to each other.</p>
406+
stacked next to each other. Note that the floats are positioned using
407+
their margin boxes, not the float area.</p>
380408
<img alt="Stacking two floats with a small shape-outside"
381409
class=singleImgExample src="images/stacked-float-example.png"></div>
382410

@@ -417,8 +445,8 @@ <h4 id=supported-basic-shapes><span class=secno>3.2.1. </span>Supported
417445
<dd>
418446
<ul>
419447
<li> The first four values represent <strong>x, y, width</strong> and
420-
<strong>height</strong>. They define the bounding box of the rectangle.
421-
Negative values for width and height are invalid.
448+
<strong>height</strong> of the rectangle. Negative values for width and
449+
height are invalid.
422450

423451
<li> The last two optional values represent <strong> rx</strong> and
424452
<strong>ry</strong>. For rounded rectangles they define the x-axis
@@ -434,9 +462,9 @@ <h4 id=supported-basic-shapes><span class=secno>3.2.1. </span>Supported
434462
<dd>
435463
<ul>
436464
<li> The first four values represent the <strong>top, right,
437-
bottom</strong> and <strong>left</strong> insets that define the
438-
bounding box of the inset rectangle. Negative values for any of these
439-
insets are invalid.
465+
bottom</strong> and <strong>left</strong> offsets from the content
466+
rectangle inward that define the positions of the edges of the inset
467+
rectangle. Negative values for any of these insets are invalid.
440468

441469
<li> The last two optional values represent <strong> rx</strong> and
442470
<strong>ry</strong>. For rounded inset rectangles they define the
@@ -572,9 +600,7 @@ <h3 id=shapes-from-image><span class=secno>3.3. </span>Shapes from Image</h3>
572600

573601
<p>The image defines its <a href="#float-area">float area</a> through the
574602
<a href="#shape-outside"><code
575-
class=property>shape-outside</code></a>’ property and specifies a value
576-
of 35 pixels for the ‘<a href="#shape-margin"><code
577-
class=property>shape-margin</code></a>’ property.
603+
class=property>shape-outside</code></a>’ property.
578604

579605
<pre><code class=html>
580606
&lt;p&gt;
@@ -585,47 +611,37 @@ <h3 id=shapes-from-image><span class=secno>3.3. </span>Shapes from Image</h3>
585611
&lt;style&gt;
586612
#CSSlogo {
587613
float: left;
588-
shape-outside: url("CSS-logo1s.png");
614+
shape-outside: attr(src url);
589615
shape-image-threshold: 0.1;
590-
shape-margin: 35px;
591616
}
592617
&lt;/style&gt;</code></pre>
593618

594-
<p>The image needs two references to the image because this example uses
595-
the same image
596-
597-
<ol>
598-
<li>to render it
599-
600-
<li>as a shape defining the <a href="#float-area">float area</a> of the
601-
image
602-
</ol>
619+
<p>The shape-outside property re-uses the url from the src attribute of
620+
the img element.
603621

604622
<p>It is perfectly possible to display an image and use a different image
605623
for its <a href="#float-area">float area</a>.
606624

607625
<p>In the figure below, the alpha-channel threshold is represented by the
608-
dotted line around the CSS logo and the 35px shape-margin is visible
609-
between that line and the edges of each individual line of the paragraph.
626+
dotted line around the CSS logo.
610627

611628
<p>It's then possible to affect where the lines of the paragraph start in
612629
three ways:
613630

614631
<ol>
615-
<li>Changing the value of the ‘<a href="#shape-margin"><code
616-
class=property>shape-margin</code></a>’ property
632+
<li>Modifying the alpha channel in the image
617633

618634
<li>Changing the value of the ‘<a href="#shape-image-threshold"><code
619635
class=property>shape-image-threshold</code></a>’ property
620636

621-
<li>Modifying the alpha channel in the image
637+
<li>Changing the value of the ‘<a href="#shape-margin"><code
638+
class=property>shape-margin</code></a>’ property (see example 8)
622639
</ol>
623640

624641
<div class=figure> <img
625-
alt="A float shape around an image using its alpha-channel with a 35 pixels shape-margin"
642+
alt="A float shape around an image using its alpha-channel"
626643
src="images/shape-outside-image.png" width="70%">
627-
<p class=caption>A float shape around an image using its alpha-channel
628-
with a 35 pixels shape-margin
644+
<p class=caption>A float shape around an image using its alpha-channel.
629645
</div>
630646
</div>
631647
<!-- End section "Shapes from image" -->
@@ -795,8 +811,9 @@ <h4 id=shape-image-threshold-property><span class=secno>3.4.2. </span>The
795811
<dt><dfn id=ltalphavaluegt
796812
title="'shape-image-threshold'!!'&lt;alphavalue&gt;'">&lt;alphavalue&gt;</dfn>
797813

798-
<dd> A &lt;number&gt; value used to set the threshold used for extracting
799-
a shape from an image. Any values outside the range 0.0 (fully
814+
<dd> A &lt;number&gt; value that sets the threshold used for extracting a
815+
shape from an image. The shape is defined by the pixels whose alpha value
816+
is greater than the threshold. Any values outside the range 0.0 (fully
800817
transparent) to 1.0 (fully opaque) will be clamped to this range.
801818
</dl>
802819
<!-- End section "The shape-image-threshold property" -->
@@ -808,9 +825,13 @@ <h4 id=shape-margin-property><span class=secno>3.4.3. </span>The ‘<a
808825

809826
<p> The ‘<a href="#shape-margin"><code
810827
class=property>shape-margin</code></a>’ property adds a margin to a
811-
shape-outside. This defines a new shape where every point is the specified
812-
distance from the shape-outside. This property takes on positive values
813-
only.
828+
shape-outside. This defines a new shape that is the smallest contour (in
829+
the shrink-wrap sense) that includes all the points that are the
830+
shape-margin distance outward in the perpendicular direction from a point
831+
on the underlying shape. Note that at points where a perpendicular is not
832+
defined (e.g. sharp points) take all points on the circle centered at the
833+
point and with a radius of shape-margin. This property takes only
834+
non-negative values.
814835

815836
<table class=propdef>
816837
<tbody>
@@ -861,6 +882,24 @@ <h4 id=shape-margin-property><span class=secno>3.4.3. </span>The ‘<a
861882
circlular shape-outside. The blue rectangles represent inline content
862883
affected by the shape created by the margin.</p>
863884
<img alt="Example of a shape-margin offset" src="images/shape-margin.png"></div>
885+
886+
<div class=example>
887+
<p>If shape-margin is added to the CSS logo from example 6, the line boxes
888+
wrapping around the shape are shortened further.
889+
890+
<pre><code class=html>
891+
#CSSlogo {
892+
shape-margin: 35px;
893+
}
894+
</code></pre>
895+
896+
<div class=figure> <img
897+
alt="A float shape around an image using its alpha-channel with a 35 pixels shape-margin"
898+
src="images/shape-outside-image-with-margin.png" width="70%">
899+
<p class=caption>A float shape around an image using its alpha-channel
900+
with a 35 pixels shape-margin
901+
</div>
902+
</div>
864903
<!-- End secion "shape-margin property" -->
865904
<!-- End section "Shapes" -->
866905

@@ -1130,6 +1169,8 @@ <h2 class=no-num id=index>Index</h2>
11301169
<li>as conformance class, <a href="#style-sheet"
11311170
title="section 4."><strong>4.</strong></a>
11321171
</ul>
1172+
1173+
<li>Wrap, <a href="#wrap" title="section 2."><strong>2.</strong></a>
11331174
</ul>
11341175
<!--end-index-->
11351176

@@ -1240,6 +1281,9 @@ <h3 class=no-num id=since-june-20th-2013>Since <a
12401281
<li>Change float positioning to be unaffected by shape-outside
12411282

12421283
<li>Shapes on floats clipped to float's margin box
1284+
1285+
<li>Inline content constrained to at least the float's farthest margin
1286+
edge
12431287
</ul>
12441288

12451289
<h3 class=no-num id=since-may-3rd-2012>Since <a

0 commit comments

Comments
 (0)