Skip to content

Commit 35b0a99

Browse files
committed
added additional techniques from Will Hardy and jawns
1 parent 8ffd957 commit 35b0a99

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

articles/css-hexagon.html

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,33 @@
155155
-o-transform: perspective(600px) rotateX(60deg);
156156
transform: perspective(600px) rotateX(60deg);
157157
}
158+
.hex3:before {
159+
content: " ";
160+
width: 0; height: 0;
161+
border-bottom: 30px solid #6C6;
162+
border-left: 52px solid transparent;
163+
border-right: 52px solid transparent;
164+
position: absolute;
165+
top: -30px;
166+
}
167+
168+
.hex3 {
169+
margin-top: 30px;
170+
width: 104px;
171+
height: 60px;
172+
background-color: #6C6;
173+
position:relative;
174+
}
175+
176+
.hex3:after {
177+
content: "";
178+
width: 0;
179+
position: absolute;
180+
bottom: -30px;
181+
border-top: 30px solid #6C6;
182+
border-left: 52px solid transparent;
183+
border-right: 52px solid transparent;
184+
}
158185
</style>
159186

160187
<div class="container">
@@ -421,9 +448,53 @@ <h1>CSS Hexagon Tutorial <span>by James Tauber</span></h1>
421448
</pre>
422449
<div style="clear: left;"></div>
423450

451+
<h2>Addendum</h2>
424452

425-
<div style="margin-bottom: 50px; float: right;">
453+
<p><b>Will Hardy</b> suggested on Twitter the following use of <code>:before</code> and <code>:after</code> to reduce the necessary <code>div</code>s to one:
454+
455+
<div style="float: left; width: 400px;">
456+
<div class="hex3"></div>
457+
</div>
458+
<pre style="margin-left: 480px;">
459+
.hex:before {
460+
content: " ";
461+
width: 0; height: 0;
462+
border-bottom: 30px solid #6C6;
463+
border-left: 52px solid transparent;
464+
border-right: 52px solid transparent;
465+
position: absolute;
466+
top: -30px;
467+
}
426468

469+
.hex {
470+
margin-top: 30px;
471+
width: 104px;
472+
height: 60px;
473+
background-color: #6C6;
474+
position: relative;
475+
}
476+
477+
.hex:after {
478+
content: "";
479+
width: 0;
480+
position: absolute;
481+
bottom: -30px;
482+
border-top: 30px solid #6C6;
483+
border-left: 52px solid transparent;
484+
border-right: 52px solid transparent;
485+
}
486+
</pre>
487+
<div style="clear: left;"></div>
488+
489+
<p><b>jawns</b> pointed out on Hacker News that there's a Unicode code point <code>U+2B22</code>:</p>
490+
491+
<div style="float: left; width: 400px;">
492+
<span style="color: #6C6; font-size: 135px">&#x2b22;</span>
493+
</div>
494+
<pre style="margin-left: 480px;">
495+
&lt;span style="color: #6C6; font-size: 135px;">&amp;#x2B22;&lt;/span>
496+
</pre>
497+
<div style="clear: left;"></div>
427498

428499

429500
<div style="margin-bottom: 50px; float: right;">

0 commit comments

Comments
 (0)