Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Start with a basic square and borders. Each border will be given a different color so we can tell them apart:</p> <pre class="lang-css prettyprint-override"><code>.triangle { border-color: yellow blue red green; border-style: solid; border-width: 200px 200px 200px 200px; height: 0px; width: 0px; } </code></pre> <p>which gives you <a href="http://jsbin.com/axoyub/5/edit">this</a>:</p> <p><a href="http://jsbin.com/axoyub/5/edit"><img src="https://i.stack.imgur.com/QH01k.png" alt="square with four borders"></a></p> <p>But there's no need for the top border, so set its width to <code>0px</code>. Now our border-bottom of <code>200px</code> will make our triangle 200px tall.</p> <pre class="lang-css prettyprint-override"><code>.triangle { border-color: yellow blue red green; border-style: solid; border-width: 0px 200px 200px 200px; height: 0px; width: 0px; } </code></pre> <p>and we will get <a href="http://jsbin.com/efihoq/2/edit">this</a>:</p> <p><a href="http://jsbin.com/efihoq/2/edit"><img src="https://i.stack.imgur.com/3gohz.png" alt="bottom half of square with four borders"></a></p> <p>Then to hide the two side triangles, set the border-color to transparent. Since the top-border has been effectively deleted, we can set the border-top-color to transparent as well.</p> <pre class="lang-css prettyprint-override"><code>.triangle { border-color: transparent transparent red transparent; border-style: solid; border-width: 0px 200px 200px 200px; height: 0px; width: 0px; } </code></pre> <p>finally we get <a href="http://jsbin.com/aluhik/2/edit">this</a>:</p> <p><a href="http://jsbin.com/aluhik/2/edit"><img src="https://i.stack.imgur.com/k9EQ8.png" alt="triangular bottom border"></a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload