<h1>Transparent CSS Triangle with Borders</h1>
<p>It's a crappy solution but it's working =)</p>
<div class="container">
<div class="triangle"></div>
</div>
<div class="demo">
<div class="container2">
<div class="triangle2"></div>
</div>
</div>
@import url(https://fonts.googleapis.com/css?family=Roboto:400,300,100,500,700);
* {
margin: 0;
padding: 0;
font-family: 'Roboto', sans-serif;
font-weight: 400;
}
body {
padding: 20px 60px;
background: url(https://images.unsplash.com/uploads/141158930417696a26471/1be620c3?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=1de98cb9239a377e266729722d2f6834&auto=format&fit=crop&w=1350&q=80) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
h1 {
margin-bottom: 20px;
color: #fff;
text-shadow: 0 0 4px #000;
}
p {
color: rgba(255,255,255,.8);
font-style: italic;
margin-bottom: 1rem;
}
.container {
width: 200px;
height: 200px;
position: relative;
border-top: 4px solid #e74c3c;
}
.triangle {
position: absolute;
margin: auto;
top: -70px;
left: 0;
right: 0;
width: 137px;
height: 137px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
border-right: 4px solid #e74c3c;
border-bottom: 4px solid #e74c3c;
}
.demo {
position: fixed;
margin: auto;
right: 0;
bottom: 0;
background: #fff;
background: rgba(255, 255, 255, .9);
width: 400px;
height: 220px;
padding-top: 120px;
}
.container2 {
width: 200px;
height: 200px;
background: transparent;
position: relative;
border-top: 2px solid #7f8c8d;
margin: 0 auto;
animation:con 6s infinite linear;
-webkit-animation:con 6s infinite linear;
border-right: 0 dashed #000;
border-left: 0 dashed #000;
border-bottom: 0 dashed #000;
}
.triangle2 {
position: absolute;
margin: auto;
top: -70px;
left: 0;
right: 0;
width: 137px;
height: 137px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
background: transparent;
border: 0px dashed #000;
border-right: 2px solid #7f8c8d;
border-bottom: 2px solid #7f8c8d;
animation:tri 6s infinite linear;
-webkit-animation:tri 6s infinite linear;
}
@keyframes con
{
0% {background: transparent;}
20% {background: red;}
40% {background: transparent;}
50% {border: 2px dashed #000;}
70% {border: none; border-top: 4px solid #e74c3c;}
100% {border: none; border-top: 4px solid #e74c3c;}
}
@-webkit-keyframes con
{
0% {background: transparent;}
20% {background: red;}
40% {background: transparent;}
50% {border: 2px dashed #000;}
70% {border: none; border-top: 4px solid #e74c3c;}
100% {border: none; border-top: 4px solid #e74c3c;}
}
@keyframes tri
{
0% {background: transparent;}
20% {background: blue;}
40% {background: transparent;}
50% {border: 2px dashed #000;}
70% {border: none; border-right: 4px solid #e74c3c; border-bottom: 4px solid #e74c3c;}
100% {border: none; border-right: 4px solid #e74c3c; border-bottom: 4px solid #e74c3c;}
}
@-webkit-keyframes tri
{
0% {background: transparent;}
20% {background: blue;}
40% {background: transparent;}
50% {border: 2px dashed #000;}
70% {border: none; border-right: 4px solid #e74c3c; border-bottom: 4px solid #e74c3c;}
100% {border: none; border-right: 4px solid #e74c3c; border-bottom: 4px solid #e74c3c;}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.