So, I'm working with this unique triangle shape represented in the image below:
The CSS used to create it is as follows:
.triangle {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 10px solid #cecece;
margin-left: -10px;
}
Here's the HTML code for the triangle:
<div class=triangle></div>
My goal is to make the triangle rotate when clicked and turn into an upside-down triangle. Can someone provide guidance on how to achieve this?
I've attempted to create a separate style for the upside-down triangle like this:
.triangle-up {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 10px solid #555;
margin-left: -10px;
}
I'm struggling to figure out how to implement the rotation effect where clicking the downward triangle turns it into an upward triangle, and vice versa. Any suggestions would be greatly appreciated!