Parallax Image Gallery using HTML, CSS & JavaScript

Parallax Image Gallery using HTML, CSS & JavaScript

Hello developers, today in this blog, you'll learn to create a Parallax Image Gallery using HTML, CSS & JavaScript.

The Image Gallery is the place, where the collection of images gets stored. Those stored images can be viewed whenever we want to see them. The parallax is a computer graphics technique used to create a faux-3D effect. The parallax effect is a difference in the apparent position of an object when viewed along two different lines of sight.

In this blog(Parallax Image Gallery), there is an image at the center of the webpage with its title at the right bottom of the image. You can see more images by scrolling horizontally by using the scroll button at the bottom of the webpage. You can add as many images as you need. This is mainly made by using Javascript.

The source code of this Parallax Image Gallery is given below, if you want the source code of this program, you can copy it. You can use this Parallax Image Gallery on your project and take it to the subsequent level.

Parallax Image Gallery [Source Code]

To make this website, you would like to make three files: an HTML file, a CSS file & a JavaScript file. First, create an HTML file with the name of index.html and remember, you have to create a file with a .html extension.

<!DOCTYPE html> <html> <head> <title>Parallax Image Gallery || Learningrobo</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <aside class="helper">Scroll sideways</aside> <main> <figure class="rellax"> <img src="https://cdn.pixabay.com/photo/2018/07/14/11/33/earth-3537401__340.jpg" alt="Network"> <figcaption class="rellax" data-rellax-speed="1">Network</figcaption> </figure> <figure class="rellax"> <img src="https://cdn.pixabay.com/photo/2021/04/26/01/39/trees-6207925__340.jpg" alt="Painting"> <figcaption class="rellax" data-rellax-speed="1">Painting</figcaption> </figure> <figure class="rellax"> <img src="https://cdn.pixabay.com/photo/2017/08/06/01/45/robot-2587571__340.jpg" alt="Robot"> <figcaption class="rellax" data-rellax-speed="1">Robot</figcaption> </figure> <div class="credit">Made with <span style="color:tomato;font-size:20px;">❤ </span>by<a href="https://www.learningrobo.com/"> Learning Robo</a></div> </main> <script type="text/javascript" src="script.js"></script> </body> </html>
CSS provides style to an HTML page. To make the page attractive, create a CSS file with the name style.css, and remember that you have to make a file with a .css extension.


@import url('https://fonts.googleapis.com/css2?family=Neonderthaw&family=Roboto+Slab:wght@100&display=swap');

* {
  box-sizing: border-box;
  border-radius: 5px;
}

body {
  background: #eee;
}

main {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 100vw 100vw 100vw;
  width: 300vw;
  justify-content: center;
  align-items: center;
}

figure {
  max-width: 45vw;
  margin: 0 auto;
  background: rgba(255,255,255,0.8);
  padding: 2em;
  border: 1px solid #ddd;
  box-shadow: 0 0 2em -0.5em #aaa;
  position: relative;
}

figure img {
  max-width: 100%;
  max-height: 70vh;
}

figure figcaption {
  font-family: "Playfair Display";
  font-weight: 900;
  font-size: 3em;
  font-style: italic;
  text-align: right;
  text-shadow: 0 0 1em #555;
  text-shadow: 0 0 0.5em white;
  position: absolute;
  right: 10px;
  bottom: -2rem;
}

.helper {
  position: absolute;
  top: 0;
  left: 0;
  margin: 1rem;
  text-align: center;
  font-family: 'Nunito Sans';
  opacity: .45;
  font-size: 1.2em;
  transition: opacity, .15s;
}
.helper:hover {
  opacity: 1;
}
.credit a {
  text-decoration: none;
  color: #000;
  font-weight: 800;
}
.credit {
  text-align: center;
  font-family: Verdana,Geneva,Tahoma,sans-serif;
}
JavaScript makes the page work functionally. At last, create a JavaScript file with the name of script.js, and remember that you've got to make a file with a .js extension.


var rellax = new Rellax('.rellax',{horizontal: true, vertical: false, speed: 1.5});
We hope you will like this Parallax Image Gallery using HTML, CSS & JavaScript.

Thank you for reading our blog. If you face any problem creating this Parallax Image Gallery using HTML, CSS & JavaScript, then contact us or comment us. We'll try to provide a solution to your problem as soon as possible.

Thank you
Learning robo team

إرسال تعليق

Thank you
Learning robo team

Post a Comment (0)

أحدث أقدم
Learning Robo says...
code copied
Welcome