Created
January 22, 2013 04:37
-
-
Save mismith/4592062 to your computer and use it in GitHub Desktop.
How to make 3-corner-rounded triangle in CSS (SO)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* How to make 3-corner-rounded triangle in CSS (SO) | |
* http://stackoverflow.com/q/14446677/1397351 | |
*/ | |
.triangle { | |
position: relative; | |
background-color: orange; | |
text-align: left; | |
} | |
.triangle:before, | |
.triangle:after { | |
content: ''; | |
position: absolute; | |
background-color: inherit; | |
} | |
.triangle, | |
.triangle:before, | |
.triangle:after { | |
width: 10em; | |
height: 10em; | |
border-top-right-radius: 30%; | |
} | |
.triangle { | |
transform: rotate(-60deg) skewX(-30deg) scale(1,.866); | |
} | |
.triangle:before { | |
transform: rotate(-135deg) skewX(-45deg) scale(1.414,.707) translate(0,-50%); | |
} | |
.triangle:after { | |
transform: rotate(135deg) skewY(-45deg) scale(.707,1.414) translate(50%); | |
} | |
/* styles below for demonstration purposes only */ | |
body { padding: 30%; } | |
.triangle:hover { background: rgba(0,0,255,.5) } | |
.triangle:hover:before { background: rgba(255,0,0,.5) } | |
.triangle:hover:after { background: rgba(255,255,0,.5) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- content to be placed inside <body>…</body> --> | |
<div class='triangle'></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// alert('Hello world!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"view":"split-vertical","fontsize":"80","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment