I am looking to create a unique animated effect for the arrows on a button, where they rotate 180 degrees each time the button is clicked.
The concept involves rotating both sides of the arrow (which are constructed using div elements) every time the containing div that houses these arrow divs is clicked.
I attempted to achieve this using Toggle but encountered some issues. Below is my code:
.button-back {
width: 50px;
height: 50px;
background-color: #fff;
border-radius: 100%;
position: absolute;
display: flex;
flex-direction: column;
justify-content: center;
transition: background-color 0.3s;
cursor: pointer;
}
.button-back:hover {
background-color: #2da6ff;
}
.left {
left: 5%;
}
.right {
right: 5%;
}
#left-top {
margin-bottom: 3px;
width: 15px;
height: 3px;
position: relative;
transform: rotate(-45deg);
left: 30%;
background: #e2e2e2;
z-index: 3;
}
#left-bottom {
margin-top: 3px;
width: 15px;
height: 3px;
position: relative;
transform: rotate(45deg);
left: 30%;
background: #e2e2e2;
z-index: 3;
}
#right-top {
margin-bottom: 3px;
width: 15px;
height: 3px;
position: relative;
transform: rotate(45deg);
left: 40%;
background: #e2e2e2;
}
#right-bottom {
margin-top: 3px;
width: 15px;
height: 3px;
position: relative;
transform: rotate(-45deg);
left: 40%;
background: #e2e2e2;
}
<div class="button-back left">
<div id="left-top"></div>
<div id=left-bottom></div>
</div>
<div class="button-back right">
<div id="right-top"></div>
<div id="right-bottom"></div>
</div>
Thank you!