GithubHelp home page GithubHelp logo

elsunny / parallax-css Goto Github PK

View Code? Open in Web Editor NEW

This project forked from seanqureshi/parallax-css

0.0 0.0 0.0 271 KB

Workshop on true parallax effect created purely in CSS

HTML 21.65% CSS 78.35%

parallax-css's Introduction

True parallax effect made entirely in CSS. Find additional comments in the index.html and style.css files.

<div class="container-for-parallax-layers">
  <div class="background layer"></div>
  <div class="midground layer"></div>
  <div class="foreground layer"></div>
</div>
.layer {
  /* Positioning is important for good parallax ... */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0;
  /* ... and so is adding some extra space for scrolling ... */
  padding-top: 10vh;
  padding-bottom: 100vh;

}

.container-for-parallax-layers {
  /* ... but the magic here is primarily in (1) the perspective property ... */
  perspective: 1px;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: scroll;
}


.background {
  /* and (2) the translateZ property (as well as the scale property). */
  /* To calculate scale, divide absolute value of translateZ by perspective and add 1 */
  transform: translateZ(-2px) scale(3);
  background-image: url("img/mountain.png");
  background-repeat: no-repeat;
  background-size: cover;
}

.midground {
  transform: translateZ(-1px) scale(2);
  background-image: url("img/treeline-midd.png");
  background-repeat: no-repeat;
  background-size: cover;
}

.foreground {
  transform: translateZ(0);
  background-image: url("img/treeline-fore.png");
  background-repeat: no-repeat;
  background-size: cover;
}

For more information, see Pure CSS Parallax Websites by Keith Clark: http://keithclark.co.uk/articles/pure-css-parallax-websites/

parallax-css's People

Contributors

alan-miller avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.