Vertical Range Slider Using HTML CSS

Vertical Range Slider Using HTML CSS
Code Snippet:iOS like vertical range input
Author: BG
Published: January 18, 2024
Last Updated: January 22, 2024
Downloads: 1,461
License: MIT
Edit Code online: View on CodePen
Read More

This HTML and CSS code helps you to create a vertical range slider. It allows users to select a value within a specified range by sliding a thumb up and down. The slider comes with a unique appearance and user-friendly interface. This code is helpful for creating interactive interfaces with vertical range selection.

You can use this code to create vertical range sliders for customizing product filters, adjusting settings, or creating interactive data visualization tools.

How to Create Vertical Range Slider Using HTML CSS

1. Start by creating an HTML file and adding the necessary structure. The following code includes a basic HTML structure with two range sliders inside div elements. You can customize the min, max, and step attributes to fit your specific needs.

<div class="wrapper">
	<input type="range" min="0" max="100" value="50" />
</div>

<div class="wrapper">
	<input type="range" min="0" max="100" value="50" step="12.5" />
</div>

2. The CSS code included in the example enhances the visual appeal of the range sliders. It defines the appearance, positioning, and styling of the sliders. You can modify the CSS to match your website’s design or create a unique look.

@charset "UTF-8";
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  margin: 0 auto;
  background-color: #05051a;
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
}

.wrapper {
  position: relative;
  height: 20rem;
  width: 3rem;
}
.wrapper::before, .wrapper::after {
  display: block;
  position: absolute;
  z-index: 99;
  color: #fff;
  width: 100%;
  text-align: center;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.75rem 0;
  pointer-events: none;
}
.wrapper::before {
  content: "+";
}
.wrapper::after {
  content: "−";
  bottom: 0;
}

input[type=range] {
  -webkit-appearance: none;
  background-color: rgba(255, 255, 255, 0.2);
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 0;
  padding: 0;
  width: 20rem;
  height: 3.5rem;
  transform: translate(-50%, -50%) rotate(-90deg);
  border-radius: 1rem;
  overflow: hidden;
  cursor: row-resize;
}
input[type=range][step] {
  background-color: transparent;
  background-image: repeating-linear-gradient(to right, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.2) calc(12.5% - 1px), #05051a 12.5%);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 0;
  box-shadow: -20rem 0 0 20rem rgba(255, 255, 255, 0.2);
}
input[type=range]::-moz-range-thumb {
  border: none;
  width: 0;
  box-shadow: -20rem 0 0 20rem rgba(255, 255, 255, 0.2);
}

Feel free to customize the code further to suit your project. You can change colors, sizes, and other CSS properties to match your website’s style.

That’s all! hopefully, you have successfully created a Vertical Range Slider in your web/app project. If you have any questions or suggestions, feel free to comment below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link

X