We see triangles everywhere: on tooltips, dropdowns and even on loading animations. Like it or not, these small elements are quite important when trying to build some relationships between various UI elements.
There are some different ways to build a triangle for your web designs and in this article you’ll see how you can actually do that.
Assuming you already created your custom triangle image and you want to save a valuable HTTP request, then converting it into a base64 string is the best solution.
This is also a pretty common technique used on stuff like tooltips and dropdowns. Together with the above, this is one of my favorite methods for creating small and useful triangles.
text-shadow
property.
text-shadow
.
Don’t forget to check this wonderful resource: http://copypastecharacter.com/.
Besides using an entity, if you’re already using an iconic font in your project, then you can simply use an arrow symbol from the available ones (in case there is one).
Basically, for this technique to work, you’ll need two blocks. But, it’s not mandatory to use two elements, so you can use an element with a pseudo-element for example.
overflow: hidden
to the wrapping block to show just the part we’re interested in.
Having the following
canvas
element in your HTML file:
… here’s how to draw a triangle using JavaScript:
This is how you can define an inline SVG triangle in your markup:
Then, just add some styles:
.svg-triangle{
margin: 0 auto;
width: 100px;
height: 100px;
}
.svg-triangle polygon {
fill:#98d02e;
stroke:#65b81d;
stroke-width:2;
}
Let me know your thoughts about these ways to build triangles, what is the method you use more often?
A great font/script for creating beautiful logos, posters, wedding invitations, blog posts, social media, and…
Realistic T-Shirt Mockup PSD which you can use freely to showcase your apparel design.
Classic coffee mug Mock-up Free PSD. Free mug mockup PSD to showcase your branding design…
Juliette - Stylish Handwritten Signature Font
XXII Aven Font Family - a new modern all-caps sans serif font with versatility in creativity.