- 32 CSS Triangles
- Author
- Links
- Made with
- About a code
- Pyramid Triangle: Pure CSS Animation
- Author
- Links
- Made with
- About a code
- CSS Tri Spinner
- Author
- Links
- Made with
- About a code
- CSS Only Triangle with Rounded Corners
- Author
- Links
- Made with
- About a code
- Moving on a Penrose Triangle
- Author
- Links
- Made with
- About a code
- Slicing Triangles
- Author
- Links
- Made with
- About a code
- CSS 3D Triangle Spin
- Author
- Links
- Made with
- About a code
- Bordered Image Triangle
- Author
- Links
- Made with
- About a code
- Triangle Grid with nth-child
- Author
- Links
- Made with
- About a code
- Triangle
- Author
- Links
- Made with
- About the code
- Triangle
- Author
- Links
- Made with
- About the code
- Rotating Rounded Triangles Animation
- Author
- Links
- Made with
- About a code
- Landscape in a Triangle
- Author
- Links
- Made with
- About a code
- Pure CSS Prism Grid Wave
- Author
- Links
- Made with
- About the code
- CSS Penrose Triangle
- Author
- Links
- Made with
- About the code
- Pure CSS Animated Triangle Grid
- Author
- Links
- Made with
- About the code
- Triangle Cutout
- Author
- Links
- Made with
- About the code
- CSS Triangles
- Author
- Links
- Made with
- About the code
- Author
- Links
- Made with
- About the code
- Pink Triangles
- Author
- Links
- Made with
- About the code
- Triangle
- Author
- Links
- Made with
- About the code
- Double Triangle
- Author
- Links
- Made with
- About the code
- Penrose Triangle
- Author
- Links
- Made with
- About the code
- Triangles
- Author
- Links
- Made with
- About a code
- Triangle
- Author
- Links
- Made with
- About the code
- Penrose Triangle x3
- Author
- Links
- Made with
- About the code
- Penrose Triangle
- Author
- Links
- Made with
- About a code
- Reverse clip-path with Blend Modes
- Author
- Links
- Made with
- About the code
- Quick Gradient Triangle Mixin
- Author
- Links
- Made with
- About the code
- Chromatic Triangle
- Author
- Links
- Made with
- About the code
- Negative Triangle SASS Mixin
- Author
- Links
- Made with
- About the code
- Centroid-Centred CSS Triangle
- Author
- Creating rounded triangles in CSS with clip-path
- By Sebastiano Guerriero Follow author on Twitter
- Let’s do this! #
32 CSS Triangles
Collection of hand-picked free HTML and CSS triangle code examples from CodePen, GitHub, and other resources. Update of February 2021 collection. Nine new items.
Author
Links
Made with
About a code
Pyramid Triangle: Pure CSS Animation
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
CSS Tri Spinner
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
CSS Only Triangle with Rounded Corners
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Moving on a Penrose Triangle
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Slicing Triangles
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
CSS 3D Triangle Spin
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Bordered Image Triangle
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Triangle Grid with nth-child
Creating a grid of triangles with CSS Grid and custom properties.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Triangle
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Triangle
Animated triangle in pure CSS.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Rotating Rounded Triangles Animation
Rotating rounded triangles animation. Rounded triangles black and white. Pug. SCSS. Animation degrees.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Landscape in a Triangle
Only-triangles landscape in a triangle. Animated through the seasons.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Pure CSS Prism Grid Wave
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
CSS Penrose Triangle
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Pure CSS Animated Triangle Grid
ure CSS animated triangle grid pop with grid , variables , clip-path .
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Triangle Cutout
Triangle cutout with pseudo-elements.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
CSS Triangles
CSS triangle / equilateral triangle: arrow with empty space, arrow without empty space, an equilateral triangle.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Pink Triangles
CSS only pink animated triangles.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Triangle
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Double Triangle
Text cards with double triangles.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Penrose Triangle
The Penrose Triangle, also known as the impossible tribar, created by the Swedish artist Oscar Reutersvärd. Created using HTML and SCSS only.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Triangles
A little CSS representation of the Compilerbau «North Wall» album cover, with a nifty little bonus hover state.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About a code
Triangle
SVG triangle with GIF background.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Penrose Triangle x3
Pure CSS penrose triangle x3.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Penrose Triangle
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Reverse clip-path with Blend Modes
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Quick Gradient Triangle Mixin
Threw a really quick mixin to make triangle gradients.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Chromatic Triangle
Try to change the $rings value and -30.times do .
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Negative Triangle SASS Mixin
Create negative triangles with this SASS mixin that leverages the power of the pseudo elements.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Centroid-Centred CSS Triangle
CSS rotations centre on bounding boxes, so triangles are not rotated on their centroid. Using the :after pseudo-element for the triangle, the original element may be given a height and width to create bounding box centred around the triangle’s centroid.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Creating rounded triangles in CSS with clip-path
In this quick tutorial, we’ll take a look at a practical example where the clip-path property can make your life easier. We’re going to design a CSS triangle that inherits some properties from its parent.
By Sebastiano Guerriero Follow author on Twitter
A few days ago, we updated the Tooltip component and replaced the ‘border hack’ with the clip-path method to create CSS triangles (the small arrow appearing beside the tooltip).
In this specific case, using clip-path brought a few advantages. We’re going to take a look at them, as well as a few other nifty CSS tricks.
👉 I’m aware the clip-path property is not supported in all browsers. However, it’s currently supported in all major browsers (except Microsoft Edge), so it’s OK to use it if what you’re creating is an enhancement and it won’t break user experience in older browsers.
Let’s do this! #
I’ve put together a video tutorial that explains how to create a ’rounded’ triangle with clip-path. Feel free to skip the video if you prefer to read the article.
Join us on our YouTube channel for more tutorials!
Probably the most popular approach to creating CSS triangles is the border hack:
If you set height and width of an element equal to 0, then apply a transparent border, if you then set only one border color (e.g., border-bottom-color) to any value you want, you end up with a triangle. It’s a cool trick, and we also have a mixin in our framework that does exactly this:
// CSS triangle @mixin triangle ($direction: up, $width: 12px, $color: red) < width: 0; height: 0; border: $width solid transparent; @if( $direction == left ) < border-right-color: $color; >@else if( $direction == right ) < border-left-color: $color; >@else if( $direction == down ) < border-top-color: $color; >@else < border-bottom-color: $color; >>
However, this method has some limitations. If we consider the tooltip case, the triangle can’t inherit the background color of the parent (you’re forced to set a variable, or to update two values). Also, if you set a border on the parent, it’s not easy to set a border on the triangle too (we’re using the border property to create the triangle itself).
An alternative approach would be using inline SVG code. Smart, but not as simple as using a or a pseudo-element.
One method I’ve been experimenting with and that seems cool consists of using the clip-path property:
The idea is simple: we turn a square into a triangle using the clip-path property. To do so, you need to pass to the polygon function three sets of coordinates:
Remember the first coordinate defines the position on the x-axis, while the second one on the y-axis.
What’s the advantage of using clip-path? For starter, we can set both background-color and border values equal to inherit. Anytime you update the style of the tooltip, the triangle is updated as well. Secondly, you can set a border radius and make the triangle. well. rounded. I realize it’s not something you plan on often doing. But still, it’s a neat trick!
What about older browsers? We can use the @support rule to show the triangle only in browsers supporting clip-path. In those that don’t, we hide the triangle.
.triangle < display: none; >@supports (clip-path: inset(50%)) < .triangle < display: block; height: 20px; width: 20px; background-color: inherit; border: inherit; position: absolute; bottom: -10px; left: calc(50% - 10px); clip-path: polygon(0% 0%, 100% 100%, 0% 100%); transform: rotate(-45deg); border-radius: 0 0 0 0.25em; >>
Is it bad? Not in this case, where the tooltip works fine without the little arrow.