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

CSS animation to make div appear smoothly from bottom

I want to make a div appear smoothly as shown in the GIF below. I assume this can be done using CSS animation but I have never worked on CSS animation before.

How to achieve it using CSS animation?

body {
background:red;
}

.container  {
background:white;
padding:20px;
position: absolute;
bottom:20px;
left:45%;
border-radius:10px;
}
<div class="container">
This is magic!
</div>

enter image description here

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

>Solution :

Yeah, this animation can be done with CSS, using @keyframes for example, like below. To close it, add a button in it, with an event listener with JavaScript.

@keyframes smooth-appear {
  to{
    bottom: 20px;
    opacity:1;
  }
}
.container {
  background: gray;
  color:white;
  padding: 20px;
  position: fixed;
  bottom: -100%;
  opacity:0;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 10px;
  animation: smooth-appear 1s ease forwards;
}
<div class="container">
  This is magic!
</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