Skip to content

Commit 4e4ff1f

Browse files
committed
[css-shapes] add stacked float example
1 parent 26a7ef7 commit 4e4ff1f

6 files changed

Lines changed: 68 additions & 4 deletions

File tree

css-shapes/Overview.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ <h3 id=relation-to-box-model-and-float-behavior><span class=secno>3.1.
364364
in yellow. The inline content only wraps around the shape.
365365

366366
<pre><code class=html>
367-
#float-left {
367+
.float-left {
368368
shape-outside: polygon(0% 50%, 50% 100%, 0 100%);
369369
float: left;
370370
width: 100px;
@@ -373,7 +373,11 @@ <h3 id=relation-to-box-model-and-float-behavior><span class=secno>3.1.
373373
}
374374
</code></pre>
375375
<img alt="Adding margin-top to a float with a small shape-outside"
376-
class=singleImgExample src="images/float-margin-example.png"></div>
376+
class=singleImgExample src="images/float-margin-example.png">
377+
<p> The next picture shows a possible result if two of these floats were
378+
stacked next to each other.</p>
379+
<img alt="Stacking two floats to show far margin edge constraint"
380+
class=singleImgExample src="images/stacked-float-example.png"></div>
377381

378382
<h3 id=basic-shapes-from-svg-syntax><span class=secno>3.2. </span>Basic
379383
Shapes</h3>

css-shapes/Overview.src.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ <h3 id="relation-to-box-model-and-float-behavior">Relation to the box model and
253253
The following styling creates a shape much smaller than the float's content area, and adds a margin-top to the float. In the picture, the shape is rendered in blue, the content area in mauve, and the margin area in yellow. The inline content only wraps around the shape.
254254
</p>
255255
<pre><code class="html">
256-
#float-left {
256+
.float-left {
257257
shape-outside: polygon(0% 50%, 50% 100%, 0 100%);
258258
float: left;
259259
width: 100px;
@@ -262,6 +262,11 @@ <h3 id="relation-to-box-model-and-float-behavior">Relation to the box model and
262262
}
263263
</code></pre>
264264
<img class="singleImgExample" src="images/float-margin-example.png" alt="Adding margin-top to a float with a small shape-outside"/>
265+
266+
<p>
267+
The next picture shows a possible result if two of these floats were stacked next to each other.
268+
</p>
269+
<img class="singleImgExample" src="images/stacked-float-example.png" alt="Stacking two floats to show far margin edge constraint"/>
265270
</div>
266271

267272
<h3 id="basic-shapes-from-svg-syntax">Basic Shapes</h3>

css-shapes/examples/float-margin-example.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@
4040
<div class="margin-area"></div>
4141
<div class="content-area"></div>
4242
<div class="shape"></div>
43-
<p>The float is positioned using the margin box. Inline content will flow through the margins of a float with shape-outside, and if the shape-outside does not fill the content box, inline content will flow through those areas as well. Line lengths are only constrained by the shape and the far margin edge.</p>
43+
<p>Inline content will flow through the margins of a float with shape-outside. If the shape-outside does not fill the content box, inline content will flow through those areas as well. Line lengths are only constrained by the shape and the far margin edge.</p>
4444
</body>
4545
</html>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5+
<title>stacking shapes with margins example</title>
6+
<!-- lots of hacks to get this to work with the old shape positioning -->
7+
<style>
8+
body {
9+
width: 300px;
10+
}
11+
.shape {
12+
float: left;
13+
width: 100px;
14+
height: 120px;
15+
background-color: lightblue;
16+
-webkit-shape-outside: polygon(1px 0px, 1px 70px, 50px 120px, 0px 120px);
17+
-webkit-clip-path: polygon(0px 0px, 0px 70px, 50px 120px, 0px 120px);
18+
}
19+
p {
20+
margin: 0;
21+
}
22+
.content-area {
23+
position: absolute;
24+
top: 28px;
25+
width: 100px;
26+
height: 100px;
27+
background-color: #B29BA3;
28+
z-index: -1;
29+
}
30+
.margin-area {
31+
position: absolute;
32+
width: 100px;
33+
height: 20px;
34+
background-color: #FFF7A5;
35+
z-index: -1;
36+
}
37+
.first {
38+
-webkit-shape-outside: polygon(1px 0px, 1px 70px, 50px 119px, 100px 120px, 0px 120px);
39+
-webkit-clip-path: polygon(0px 0px, 0px 70px, 50px 120px, 0px 120px);
40+
}
41+
.second {
42+
left: 108px;
43+
}
44+
</style>
45+
</head>
46+
<body lang="en">
47+
<div class="margin-area"></div>
48+
<div class="content-area"></div>
49+
<div class="second margin-area"></div>
50+
<div class="second content-area"></div>
51+
<div class="first shape"></div>
52+
<div class="shape"></div>
53+
<p>When floats with shapes are stacked, the far margin edge constraint keeps inline content from interacting with more than one float area per side.</p>
54+
</body>
55+
</html>
-31.9 KB
Loading
14 KB
Loading

0 commit comments

Comments
 (0)