how to animate width and height 100% using css3 animations?

It worked yesterday. picture It worked yesterday. · Apr 26, 2015 · Viewed 15.5k times · Source

I have following code

HTML

<div></div>

css

div {
    background: tomato;
    width: 100px;
    height: 100px;
    -webkit-animation: animateThis 0.3s ease-in;
    -webkit-animation-fill-mode: forwards;
}

@-webkit-keyframes animateThis {
    0% {
        width: 100px;
        height: 100px;
    }
    100% {
        width: 100%;
        height: 100%;

    }
}

DEMO

What i am trying to do is i want to scale up div's with and height to 100% to cover the whole browser. i dont know how to animate 100% height. I did a search on google. No luck found

Answer

Paulie_D picture Paulie_D · Apr 26, 2015

You need to specifiy 100% of something..in this case, the html/body

* {
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
}
div {
  background: tomato;
  width: 100px;
  height: 100px;
  -webkit-animation: animateThis 1s ease-in;
  -webkit-animation-fill-mode: forwards;
}
@-webkit-keyframes animateThis {
  0% {
    width: 100px;
    height: 100px;
  }
  100% {
    width: 100%;
    height: 100%;
  }
}
<div></div>