10

How to Create a Range Slider Using HTML & CSS?

 2 years ago
source link: https://uxplanet.org/how-to-create-a-range-slider-using-html-css-6112fe9346e4
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Responses

Also publish to my profile

There are currently no responses for this story.

Be the first to respond.

You have 2 free member-only stories left this month.

How to Create a Range Slider Using HTML & CSS?

A simple range slider tutorial.

Range sliders are used on web pages to allow the user to specify a numeric value that should not be less than a certain value and not greater than another given value. That is, it allows you to choose a value from a range represented as a slider.

Sliders allow users to view and select a value (or range) in the range along a bar. They are ideal for adjusting settings such as volume and brightness or for applying image filters.

Sliders can use icons at either end of the bar to represent a numeric or relative scale. The range of values ​​or the nature of the values, such as the change in volume, can be communicated via icons.

Sliders should not be used to adjust parameters with a delay in providing feedback to the user.

Important points:

  • Range sliders have a technical advantage over the input field as it will require less validation to be sure. For the same reason, it can benefit the user because a range slider will not generate an unnecessary error due to an “incorrect” entry.
  • They are, however, somewhat limited as they cannot allow an infinite range of numbers, which makes them impractical, for example a phone number or a date.
  • Range sliders work great when you have a strictly defined range that can only have a small number of values. For example, guest meal reservations or maybe a volume control.

The Range Slider is a very intuitive user interface with one or two handles to allow the user to choose a value within a limited range. The user drags a handle along a dimension to set a value.

A typical slider is usually found in the color picker where we can drag the arrow left and right to select the correct RGB value.

For more in-depth details about UI slider:

Creating a range slider

First, you need to create two Files one HTML File and another one is CSS File. After creating these files just paste the following codes in your file.

1. HTML:

<div class="slider">
<input type=”range” min=”0" max=”100" value=”10" oninput=”rangeValue.innerText = this.value”>
<p id=”rangeValue”>10</p>
</div>

2. CSS:

body {
background: #EFCDA4;
}
.slider {
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
width:500px;
height:60px;
padding:30px;
padding-left: 40px;
background:#fcfcfc;
border-radius:20px;
display:flex;
align-items:center;
box-shadow:0px 15px 40px #7E6D5766;
}
.slider p {
font-size:26px;
font-weight:600;
font-family: Open Sans;
padding-left:30px;
color:#7E6D57;
}
.slider input[type=”range”] {
-webkit-appearance:none !important;
width:420px;
height:2px;
background:#7E6D57;
border:none;
outline:none;
}
.slider input[type=”range”]::-webkit-slider-thumb {
-webkit-appearance:none !important;
width:30px;
height:30px;
background:#fcfcfc;
border:2px solid #7E6D57;
border-radius:50%;
cursor:pointer;
}
.slider input[type=”range”]::-webkit-slider-thumb:hover {
background:#7E6D57;
}

Final Preview:

1*DNGdLIgpBGWL4JnaBGvakg.gif?q=20
how-to-create-a-range-slider-using-html-css-6112fe9346e4

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK