Triangle Hovers
Pure CSS triangle hit-test areas with texts
by stichoza
HTML
<div id="tri-square">
<span class="float-tl">code</span>
<span class="float-br">design</span>
<div class="triangle triangle-top"></div>
<div class="triangle triangle-bottom"></div>
</div>
CSS
body {
background: url(http://i.imgur.com/tpwLZKs.jpg);
}
#tri-square {
position: fixed;
top: 50%;
left: 50%;
margin-top: -150px;
margin-left: -150px;
width: 300px;
height: 300px;
border: 2px solid #fff;
}
#tri-square .triangle {
position: absolute;
width: 216px;
height: 428px;
top: 0px;
left: 0px;
background: rgba(255,255,255,0.05);
cursor: pointer;
/* animation */
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
transition: all 0.2s linear;
/* rotation */
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
#tri-square .triangle:hover {
background: rgba(255,255,255,0.3);
}
#tri-square .triangle-top {
top: -142px;
left: -33px;
border-right: 1px solid #fff;
}
#tri-square .triangle-bottom {
top: 13px;
left: 118px;
border-left: 1px solid #fff;
}
#tri-square .float-tl, #tri-square .float-br {
position: absolute;
color: #fff;
font-family: consolas, monospace;
font-size: 1.4em;
}
#tri-square .float-tl {
top: 5px;
left: 8px;
}
#tri-square .float-br {
bottom: 5px;
right: 8px;
}