I have this example of Collapse row on mouse click:
jsfiddle.net/7bz5au97/
I would like to ask you how I can add arrow like this one at the beginning of the question and rotate it when the question is expanded?
Can this be done with CSS only or I need also to add JavaScript?
You could do this almost entirely with css:
var arr = document.querySelector('.arrow');
arr.addEventListener('click', function(event) {
event.target.classList.toggle('down');
});
.arrow {
margin: 1em;
}
.arrow::before {
position: absolute;
content: '';
width: 0;
height: 0;
border: .5em solid transparent;
border-left-color: gray;
transform-origin: 0 50%;
transition: transform .25s;
}
.arrow.down::before {
transform: rotate(90deg);
transition: transform .25s;
}
<div class="arrow"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With