Overview
Squares
Fixed
.square {
height: 200px;
width: 200px;
}
Responsive
.responsive-square {
width: 50%;
}
.responsive-square:after {
content: "";
display: block;
padding-bottom: 100%;
}
Circles
Fixed
.circle {
height: 200px;
width: 200px;
border-radius: 50%;
}
Responsive
.responsive-circle {
width: 50%;
border-radius: 50%;
}
.responsive-circle:after {
content: "";
display: block;
padding-bottom: 100%;
}
Ovals
Fixed
.oval {
height: 100px;
width: 200px;
border-radius: 50%;
}
Responsive
.responsive-oval {
width: 50%;
border-radius: 50%;
}
.responsive-oval:after {
content: "";
display: block;
padding-bottom: 50%;
}
Trapezoid
.trapezoid {
border-bottom: 100px solid #6f42c1;
border-left: 25px solid transparent;
border-right: 25px solid transparent;
height: 0;
width: 200px;
}
Rectangles
Aspect Ratios (classes taken from Bootstrap 5)
<div class="ratio ratio-1x1"></div>
<div class="ratio ratio-4x3"></div>
<div class="ratio ratio-16x9"></div>
<div class="ratio ratio-21x9"></div>
Parallelograms
.parallelogram {
width: 200px;
height: 100px;
transform: skew(20deg);
}
Triangles
Up, right, down, left
.triangle {
width: 0;
height: 0;
}
.triangle-up {
border-left: 2rem solid transparent;
border-right: 2rem solid transparent;
border-bottom: 4rem solid #6f42c1;
}
.triangle-right {
border-top: 2rem solid transparent;
border-left: 4rem solid #6f42c1;
border-bottom: 2rem solid transparent
}
.triangle-down {
border-left: 2rem solid transparent;
border-right: 2rem solid transparent;
border-top: 4rem solid #6f42c1;
}
.triangle-left {
border-left: 2rem solid transparent;
border-right: 2rem solid transparent;
border-top: 4rem solid #6f42c1;
}
.triangle-upright {
border-top: 4rem solid #6f42c1;
border-left: 4rem solid transparent;
}
.triangle-bottomright {
border-bottom: 4rem solid #6f42c1;
border-left: 4rem solid transparent;
}
.triangle-bottomleft {
border-bottom: 4rem solid #6f42c1;
border-right: 4rem solid transparent;
}
.triangle-upleft {
border-top: 4rem solid #6f42c1;
border-right: 4rem solid transparent;
}
Stars
<div class='star star-6'></div>
<div class='star star-5'></div>
.star {
width: 0;
height: 0;
}
.star-6 {
border-left: 4rem solid transparent;
border-right: 4rem solid transparent;
border-bottom: 6rem solid #6f42c1;
}
.star-5 {
transform: rotate(35deg);
border-right: 100px solid transparent;
border-bottom: 70px solid #6f42c1;
border-left: 100px solid transparent;
}
.star:after, .star:before {
width: 0;
height: 0;
content: '';
position: absolute;
display: block;
}
.star-6:after {
border-left: 4rem solid transparent;
border-right: 4rem solid transparent;
border-top: 6rem solid #6f42c1;
top: 2rem;
left: -4rem;
}
.star-5:before {
border-bottom: 80px solid #6f42c1;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
top: -45px;
left: -65px;
transform: rotate(-35deg);
}
.star-5:after {
top: 3px;
left: -105px;
border-right: 100px solid transparent;
border-bottom: 70px solid #6f42c1;
border-left: 100px solid transparent;
transform: rotate(-70deg);
}