Páginas

martes, 9 de junio de 2015

Modificar contenido según scroll javascript

 
<!DOCTYPE html>
<html>
<head></head>

<style type="text/css">
  #test00{
    height: 500px;
    outline: solid 1px rgba(0,0,0,0.5);
  }
  #test01{
    height: 500px;
    outline: solid 1px rgba(0,0,0,0.5);
  }
</style>

<body>

  <div id="test00">
  </div>

  <div id="test01">
  </div>

  <div id="test01">
  </div>

  <script type="text/javascript">
    var top = pageYOffset;

    var altopag = document.getElementById("test00").clientHeight;
    console.log(altopag);

    document.body.onscroll=function(){
      if( window.scrollY > altopag){
        console.log("rule");
        document.getElementById("test01").style.backgroundColor = "#000";
        document.body.style.backgroundColor = "#000 ";
      }else {
      document.getElementById("test01").style.backgroundColor = "#fff";
      document.body.style.backgroundColor = "#fff ";
      }
    };
  </script>

</body>
</html>

No hay comentarios:

Publicar un comentario