I have the following HTML defined:
<ul class="steps d-flex">
<li class="step">Basic Details<div class="triangle triangle-right"></div></li>
</ul>
With the following CSS:
.steps li {
@extend .text-center;
position: relative;
overflow: hidden;
flex: 1 1;
align-items: center;
justify-content: center;
background: $grey-600;
}
It looks like this:
I’d like to have a triangle pointing to the right of the div like so:
Notice how payment has a triangle that looks like it’s pointing to ‘done’
How do I do this?
2
Answers
Given your provided HTML and CSS, it looks like you’re trying to create a triangle using a div with a class of triangle-right. To make this triangle point to the right, you can use the ::before or ::after pseudo-element, coupled with the border trick to form the triangle. Here’s how you can do it:
With this CSS, the triangle will point to the right and will appear on the right side of the with the class triangle-right. Adjust the border sizes as needed to change the size of the triangle.
First, you need to create a
chevron
element. An easy way to do it using CSS. After that you can implement it to your example.I suggest you to use
flexbox
technology, it’s much easier and elegant way to complete these kind of tasks.Here is an example of your question.