Giter Club home page Giter Club logo

product-carousel's Introduction

Responsive Product Carousel (Slider)

This is a responsive product carousel (slider) built from scratch without any framework or library (just vanilla HTML, CSS, and JavaScript). It has few lines of code so is lightweight and fast. I used a class that you can create as many sliders as you want on a single webpage from it. All used images are free to use and from Unsplash.

How to Use It

First, download the repository. Then, do the next steps.

HTML Part

In the index.html file of this repository root folder, you can find, edit, or add slider's HTML codes.

Just copy and paste the div tag with slider-container class attribute value and change it's id attribute value to your suitable one.

Each li tag with the class of slider-item is a single slide. You can add more slides, remove some of them, and edit slide (slide-link-url, slide-image-file-url, and image alternative text) as you wish.

Sample code:

<div class="slider-container" id="sample-slider">
  <div class="slides-wrapper">
    <div class="slides-container">
      <ul class="slider-list">
        <li class="slider-item">
          <a href="slide-link-url">
            <img src="slide-image-file-url" alt="image alternative text" />
          </a>
        </li>
        <li class="slider-item">
          <a href="slide-link-url">
            <img src="slide-image-file-url" alt="image alternative text" />
          </a>
        </li>
        <li class="slider-item">
          <a href="slide-link-url">
            <img src="slide-image-file-url" alt="image alternative text" />
          </a>
        </li>
        <li class="slider-item">
          <a href="slide-link-url">
            <img src="slide-image-file-url" alt="image alternative text" />
          </a>
        </li>
        <li class="slider-item">
          <a href="slide-link-url">
            <img src="slide-image-file-url" alt="image alternative text" />
          </a>
        </li>
        <li class="slider-item">
          <a href="slide-link-url">
            <img src="slide-image-file-url" alt="image alternative text" />
          </a>
        </li>
      </ul>
    </div>
  </div>
  <div class="slider-arrows">
    <button type="button" class="slider-arrow-prev">Prev</button>
    <button type="button" class="slider-arrow-next">Next</button>
  </div>
</div>

JavaScript Part

In this repository > assets > js > slider.js file, do the below step.

For creating each new slider, at the bottom of the codes before }, add the below line of code and change the values (or just edit the present codes):

new Slider('sample-slider', [576, 768, 992]).run();

Instead of sample-slider, write your slider-container div tag id that you entered on the HTML part before.

The [576, 768, 992] is an array of the media queries (breaking points) where the number of displayed slides at the same time, increases. Change it as needed.

Save files. That's it! You created a new slider.

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.