Giter Club home page Giter Club logo

pure-css-parallax's Introduction

pure-css-parallax

This a template where its contains the basics for making a parallax scrolling effet on a web page

HTML part

All you have to do is to add a div tag with parallax class

Exemple

<div class="parallax-3"></div>
<div class="parallax-2"></div>
<div class="parallax-1"></div>

The numbers at the end allow to adjust the distance between objects with CSS

CSS part

For each classes, you absolutly need those properties:

position: absolute;
inset: 0;
transform-style: preserve-3d;

Then, you add z-index and transform which allow to adjust the distance and stack in the right order. In transform, you need to translate to the back with translateZ(). It has to be in negative value like -1px. You add scale() to make it to the right size. The value assigned to scale() should be additionned from the translateZ() value. For exemple, if the value in translateZ() is -1px, then the scale() should be 2:

transform: translateZ(-1) scale(2);

In sum, you should have something like this:

.parallax{
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  z-index: -1;
  transform: translateZ(-1px) scale(2);
}

pure-css-parallax's People

Contributors

shaynefortier avatar

Watchers

 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.