Double Vertical Slider with HTML CSS & JavaScript

Double Vertical Slider with HTML CSS & JavaScript

If you want to create a Vertical Image slider using html css then you have come to right place. In this article, you will learn how to create Double Vertical Slider using HTML CSS and JavaScript. Earlier I shared many more Vertical Image Slider and Responsive Image Slider tutorials.

Here I have shared the tutorial on how to make Double Vertical Slider. I used html css and javascript to create this Animated Vertical Image Slider. Are you in need of a website design for your business? Contact The Real Social Company today.

Double Vertical Slider with HTML CSS & JavaScript

We use full-page vertical slider in many places but it is a single slider. This is a double vertical image slider. If you want you can create an automatic vertical image slider using some additional javascript. It is basically a vertical product slider that is made up of product images and information.

Double Vertical Slider with HTML CSS

A vertical slider is a type of slideshow that displays images or content in a vertical orientation. It is a popular design choice for websites and applications because of its aesthetic appeal and ease of use. In this article, we will go through the steps of creating a vertical slider using HTML and CSS.

This type of Double Vertical Slider is mainly used in the hero section of the website. If you want, you can use this design source in your project because it is a responsive Double Vertical Slider.

See the Pen Double Vertical Slider - Image Gallery by Ground Tutorial (@groundtutorial) on CodePen.

As you can see above the entire slider area is divided into two parts. The width of the first part is 35% and the width of the second part is 65%. html The first part of the Double Vertical Slider deals with displaying text and basic information.

In the second part of this Vertical Split Image Slider, only images are shown. Then there are two control buttons. The slider of vertical slider in html can be changed by that control button.

Vertical Image Slider Using HTML,CSS & JavaScript

Now you will know how to create html Double Vertical Slider. Here I have not shared any step by step tutorial as this design is very simple. I have directly given below the codes to create this CSS Slider Vertical. You can copy it if you want. Besides, you will get the complete code of full page vertical slider below the article.

1. HTML Code of Double Vertical Slider

The following codes are the HTML code of this Animated Vertical Image Slider.

				
					    <div class="slider-container">
      <div class="left-slide">
        <div style="background-color: #b99f8a">
          <h1>Pareos</h1>
          <p>new collection</p>
        </div>
        <div style="background-color: #354f32">
          <h1>Swimsuits</h1>
          <p>new collection</p><div class='code-block code-block-8' style='margin: 8px 0; clear: both;'> <script type="litespeed/javascript" data-src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2145094925886663"
     crossorigin="anonymous"></script> <ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-2145094925886663"
     data-ad-slot="9706922910"></ins> <script type="litespeed/javascript">(adsbygoogle=window.adsbygoogle||[]).push({})</script></div>

        </div>
        <div style="background-color: #657e85">
          <h1>Crop Tops</h1>
          <p>new collection</p>
        </div>
        <div style="background-color: #2b2e32">
          <h1>Accessories</h1>
          <p>new collection</p><div class='code-block code-block-9' style='margin: 8px 0; clear: both;'> <script type="litespeed/javascript" data-src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2145094925886663"
     crossorigin="anonymous"></script> <ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-2145094925886663"
     data-ad-slot="7515873849"></ins> <script type="litespeed/javascript">(adsbygoogle=window.adsbygoogle||[]).push({})</script></div>

        </div>
      </div>
      <div class="right-slide">
        <div
          style="
            background-image: url('https://images.unsplash.com/photo-1567640157569-f93dc2275420?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
          "
        ></div>
        <div
          style="
            background-image: url('https://images.unsplash.com/photo-1552996923-5063f7db50ee?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80');
          "
        ></div>
        <div
          style="
            background-image: url('https://images.unsplash.com/photo-1559992490-51463933f67e?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=1350&q=80');
          "
        ></div>
        <div
          style="
            background-image: url('https://images.unsplash.com/photo-1561076722-85adfb3195cb?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=1350&q=80');
          "
        ></div>
      </div>
      <div class="action-buttons">
        <button class="down-button">
          <i class="fas fa-arrow-down"></i>
        </button>
        <button class="up-button">
          <i class="fas fa-arrow-up"></i>
        </button>
      </div>
    </div>
				
			

2. Responsive Vertical Slider CSS Code

Custom codes are CSS codes that help design and style this Vertical Slider image slider. First here are some basic designs on the slider. Then left sidebar and right sidebar are designed.

				
					* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Open Sans", sans-serif;
  height: 100vh;
}

.slider-container {
  position: relative;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

.left-slide {
  height: 100%;
  width: 35%;
  position: absolute;
  top: 0;
  left: 0;
  transition: transform 0.5s ease-in-out;
}

.left-slide > div {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.left-slide h1 {
  font-size: 40px;
  margin-bottom: 10px;
  margin-top: -30px;
}

.right-slide {
  height: 100%;
  position: absolute;
  top: 0;
  left: 35%;
  width: 65%;
  transition: transform 0.5s ease-in-out;
}

.right-slide > div {
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  height: 100%;
  width: 100%;
}

button {
  background-color: #fff;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 16px;
  padding: 15px;
}

button:hover {
  color: #222;
}

button:focus {
  outline: none;
}

.slider-container .action-buttons button {
  position: absolute;
  left: 35%;
  top: 50%;
  z-index: 100;
}

.slider-container .action-buttons .down-button {
  transform: translateX(-100%);
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
}

.slider-container .action-buttons .up-button {
  transform: translateY(-100%);
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
}

				
			

3. JavaScript for Double Vertical Slider

Now this project (Vertical Image Slider Using HTML,CSS & JavaScript) has to be implemented using JavaScript. Here I have used very simple javascript code. I have fully explained the javascript code used here so you won’t have any difficulty in understanding.

If you know basic JavaScript then you can create Double Vertical Image Slider very easily.

				
					const sliderContainer = document.querySelector(".slider-container");
const slideRight = document.querySelector(".right-slide");
const slideLeft = document.querySelector(".left-slide");
const upButton = document.querySelector(".up-button");
const downButton = document.querySelector(".down-button");
const slidesLength = slideRight.querySelectorAll("div").length;

let activeSlideIndex = 0;

slideLeft.style.top = `-${(slidesLength - 1) * 100}vh`;

const changeSlide = (direction) => {
  const sliderHeight = sliderContainer.clientHeight;
  if (direction === "up") {
    activeSlideIndex++;
    if (activeSlideIndex > slidesLength - 1) activeSlideIndex = 0;
  } else if (direction === "down") {
    activeSlideIndex--;
    if (activeSlideIndex < 0) activeSlideIndex = slidesLength - 1;
  }
  slideRight.style.transform = `translateY(-${
    activeSlideIndex * sliderHeight
  }px)`;
  slideLeft.style.transform = `translateY(${
    activeSlideIndex * sliderHeight
  }px)`;
};

upButton.addEventListener("click", () => changeSlide("up"));
downButton.addEventListener("click", () => changeSlide("down"));

				
			

The first section selects elements from the HTML document using the DOM API. The selected elements include the slider container, two slide elements (right and left), two buttons (up and down), and the number of slides by counting the number of “div” elements within the right slide element.

The “activeSlideIndex” variable is initialized to 0 and is used to keep track of which slide is currently being displayed in the slider component.

The initial position of the left slide element is set using the “slideLeft.style.top” property.

The “changeSlide” function takes a “direction” argument, which can be either “up” or “down”. The function updates the “activeSlideIndex” variable and sets the “transform” property of the right and left slide elements to change the position of the slides. The “translateY” CSS function is used to translate the elements along the Y-axis.

Finally, the up button and down button are assigned event listeners using the “addEventListener” method. The “click” event triggers the “changeSlide” function and passes the appropriate “direction” argument when the buttons are clicked.

Hope you have been able to create this project (Double Vertical Slider using Html Css & JavaScript) using the above codes. Earlier I have shared many more image slider tutorials with you. You can see those designs if you want.

This Double Vertical Product Slider is fully responsive so you can easily use it for any of your work. Please comment how you like this Vertical Image Slider Using HTML,CSS.

A vertical slider can be created in HTML and CSS using the following steps:

  1. HTML structure: Create a container element for the slider and two child elements for the slides. For example, you can create a “slider-container” class element that contains two “slide” class elements.
<div class="slider-container">
<div class="slide">Slide 1</div>
<div class="slide">Slide 2</div>
</div>
  1. CSS: Use CSS to set the width and height of the slider container and the slides. Also, set the position of the slides to absolute and set the top property of the second slide to the height of the container.
.slider-container {
position: relative;
width: 100%;
height: 300px;
overflow: hidden;
}

.slide {
position: absolute;
width: 100%;
height: 100%;
}

.slide:nth-child(2) {
top: 100%;
}
  1. JavaScript: Use JavaScript to toggle the top property of the slides to switch between the two slides. You can add buttons or use any other interaction method to trigger the toggle.
const sliderContainer = document.querySelector('.slider-container');
const slides = sliderContainer.querySelectorAll('.slide');
let currentSlide = 0;

const toggleSlide = () => {
slides[currentSlide].style.top = '-100%';
currentSlide = currentSlide === 0 ? 1 : 0;
slides[currentSlide].style.top = '0';
}

document.querySelector('.toggle-button').addEventListener('click', toggleSlide);

To create a multiple image slider in HTML and CSS, you need to follow these steps:

  1. HTML structure: Create a container for the slider and inside it, add two divs for the slides. One for the right side and one for the left side. You can also add buttons for navigation.

  2. CSS styling: Style the container and the two slide divs to have the desired width and height. You can also add styles for the buttons.

  3. Adding images: Add images to the slide divs as background images and adjust the background-position property to create a sliding effect.

  4. JavaScript functionality: Use JavaScript to add functionality to the navigation buttons and change the background-position property on button click.

  5. Testing: Test the slider to make sure it works as expected and make any necessary adjustments.

Note: You can use CSS transitions to create a smooth sliding effect.

Here are the steps to make a vertical slider in HTML and CSS:

  1. Create a container element for your slider, for example, a div element with a class of “slider-container”.
  2. Inside the container element, create two more elements, one for the right side of the slider and another for the left side of the slider, each with a different class name.
  3. For each slide, create a separate div element within the right and left elements.
  4. Style the slider container to have a specific height and width and to be positioned relatively.
  5. Style the right and left elements with a fixed height and width, positioned absolutely within the container, and set their top and bottom properties to 0.
  6. Style each slide to have the same height and width as the right and left elements and position them absolutely within their respective elements.
  7. Use CSS transform: translateY() property to control the vertical movement of the slides within the right and left elements.
  8. Add navigation buttons, for example, up and down buttons, to control the movement of the slides.
  9. Use JavaScript to detect the button clicks and update the transform property of the right and left elements accordingly.
  10. Optionally, you can add styles for active and inactive slides, animations, and responsiveness to enhance the overall look and functionality of your slider.

To create a vertical carousel in HTML, you need to follow these steps:

  1. Create the HTML structure: Start by creating a container for your carousel and define the individual slides within it using the appropriate HTML tags such as divs or sections.

  2. Style the container:

  3. Style the slides: 

  4. Implement the carousel functionality: 

  5. Implement the slide transition:  

  6. Add navigation elements:  

  7. Fine-tune the styling and functionality as needed: 

Here are the steps to create a vertical image slider using HTML, CSS and JavaScript:

  1. Create an HTML structure: Create a container element to hold the slider and add two other elements, one for the slides to be displayed on the right and the other for slides to be displayed on the left. Each slide should be in a separate div element.

  2. Add CSS styles

  3. Use JavaScript to change slides

  4. Add event listeners

  5. Customize the slider