* Add autoscoping with generated demo * Remove manual demo from all snippets * Add JavaScript inside IIFE * Align mouse-cursor-gradient-tracking.md to demo code * Match snippets to demo * Update CONTRIBUTING.md * Create reusable function for code extraction
777 B
777 B
Triangle
Creates a triangle shape with pure CSS.
HTML
<div class="triangle"></div>
CSS
.triangle {
width: 0;
height: 0;
border-top: 20px solid #333;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
}
Demo
Explanation
View this link for a detailed explanation.
The color of the border is the color of the triangle. The side the triangle tip points
corresponds to the opposite border-* property. For example, a color on border-top
means the arrow points downward.
Experiment with the px values to change the proportion of the triangle.
Browser support
✅ No caveats.