javascript - Why during animation between two 'div' there is an empty space? -


can me remove white space in between them during animation?

do need add 1 more div wrap both div one?

i have chosen use position-top adjust div animations causing problem , please suggest me better method animation if any?

<!doctype html>  <html>    <head>      <style>          #top {              background: white;              color: white;              width: 300px;              height: 300px;              display: inline-block;              overflow: hidden;          }            #first {              background: blue;              transition: 0.5s;              height: 300px;              position: relative;          }            #second {              background: green;              transition: 0.5s;              height: 300px;              position: relative;          }      </style>      <script>          var = true;          var down = false;          function animations() {              if (up) {                  document.getelementbyid('first').style.top = '-300px';                  document.getelementbyid('second').style.top = '-300px';                  = false;                  down = true;              }              else if (down) {                  document.getelementbyid('first').style.top = '0px';                  document.getelementbyid('second').style.top = '300px';                  down = false;                  = true;              }          }            //timer events          var startanimations = setinterval(animations, 1000);      </script>  </head>    <body>      <div id="top">          <div id="first">first</div>          <div id="second">second</div>      </div>  </body>    </html>

while moving down make second div element top 0px instead of 300px;

hope helps.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -