Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to animate standing line with css

I want to animate a standing line from top to bottom using pure CSS. I have done it but the transform property also gets animated.

.line {
  width: 5rem;
  height: 1px;
  background-color: black;
  position: absolute;
  top: 3rem;
  left: 3rem;
  transform: rotate(90deg);
  animation: stand linear 1s;
}
@keyframes stand {
  0% {width: 0;}
  100% {width: 5rem;}
}
<div class="line"></div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

That’s because the animation applies for the whole element. Instead of rotating the element and then adjusting its width for the animation, you could do the same think but adjust its height.

.line {
  width: 1px;
  height: 5rem;
  background-color: black;
  position: absolute;
  top: 3rem;
  left: 3rem;
  animation: stand linear 1s;
}
@keyframes stand {
  0% {height: 0;}
  100% {height: 5rem;}
}
<div class="line"></div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading