How to make transition dependent on block height?
How can I implement the transition effect with a formula using js or css? I need the transition speed to depend on the height of the block. Tell me how can I implement this?
element.getBoundingClientRect().height it will return a pixel value (without the unit) . that value you can pass to CSS with a custom property and calculate with thatelement.getBoundingClientRect().heightconst element = document.querySelector(".myElement");
element.style.setProperty('--height', element.getBoundingClientRect().height).myElement{
transition-duration: calc(0.5s * var(--height));
}