I have a simple accordion, a transition property on maxHeight. The clickevent listener is on the parent ul element when I toggle between the max-height(click event) why does all the elements shift to the left slightly? (This happens only to the 2nd and 3rd ul element i.e"Web Development" and "AI and Machine Learning") Can someone help me understand
Here is the codepen
https://codepen.io/sabgalaxy/pen/XWJXGWy
let containers = document.getElementsByClassName("container");
for(let container of containers){
container.addEventListener("click",() => {
/*Get the child ul element*/
let dropdownElement = container.childNodes[1].childNodes[7];
if (dropdownElement.style.maxHeight) {
dropdownElement.style.maxHeight = null;
} else {
dropdownElement.style.maxHeight = dropdownElement.scrollHeight + "px";
}
});
}