|
155 | 155 | -o-transform: perspective(600px) rotateX(60deg); |
156 | 156 | transform: perspective(600px) rotateX(60deg); |
157 | 157 | } |
| 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 | + } |
158 | 185 | </style> |
159 | 186 |
|
160 | 187 | <div class="container"> |
@@ -421,9 +448,53 @@ <h1>CSS Hexagon Tutorial <span>by James Tauber</span></h1> |
421 | 448 | </pre> |
422 | 449 | <div style="clear: left;"></div> |
423 | 450 |
|
| 451 | +<h2>Addendum</h2> |
424 | 452 |
|
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 | +} |
426 | 468 |
|
| 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">⬢</span> |
| 493 | +</div> |
| 494 | +<pre style="margin-left: 480px;"> |
| 495 | +<span style="color: #6C6; font-size: 135px;">&#x2B22;</span> |
| 496 | +</pre> |
| 497 | +<div style="clear: left;"></div> |
427 | 498 |
|
428 | 499 |
|
429 | 500 | <div style="margin-bottom: 50px; float: right;"> |
|
0 commit comments