Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize only with css for html5 input range slider-vertical?

I would like to customize the look of a html5 input[range] when it's vertical.

Want to avoid CSS 3 directive like transform:rotate, it complicates the UI layout then.

Webkit css properties are recognised in my context, the others vendors are useless in my case.

The customisation works good for the horizontal default slider, but not for the vertical one, you can look at here :

jsFiddle : http://jsfiddle.net/QU5VD/1/

Otherwise, here's the code :

HTML

<input type="range" class="vHorizon" />

<input type="range" class="vVertical" />

CSS

input[type="range"].vHorizon {
   -webkit-appearance: none;
   background-color: pink;
   width: 200px;
   height:10px;
}
input[type="range"].vVertical {
   -webkit-appearance: slider-vertical;
   background-color: pink;
   width: 10px;
   height:200px;
}
input[type="range"]::-webkit-slider-thumb {
   -webkit-appearance: none;
   background-color: red;
   width: 20px;
   height: 20px;
}
like image 369
medCoder Avatar asked May 28 '13 16:05

medCoder


People also ask

How do you make a vertical slider in html and CSS?

For Chrome, use -webkit-appearance: slider-vertical . For IE, use writing-mode: bt-lr . For Firefox, add an orient="vertical" attribute to the html.

How do you make a vertical slider in CSS?

Add the following custom CSS to your website to adjust the height of the range slider. It is possible to add this using a WS Form HTML field with the CSS wrapped in <style> tags. Change the CSS variable --wsf-range-vertical-height (line 2) to any height you wish. It is set to 200 pixels by default.

How do you style range input in CSS?

To style the range input with CSS you'll need to apply styles to two pseudo-elements: ::-webkit-slider-thumb and ::-webkit-slider-runnable-track . Find out how you can apply custom styling and make the range input more functional and appealing.


1 Answers

******UPDATED ANSWER****

If i understand you correctly, you are trying to make you vertical look like what your horizontal looks like? if so:

    input[type=range].vVertical {
    -webkit-appearance: none;
    background-color: green;
    width: 200px;
    height:10px;

      -webkit-transform:rotate(90deg);       
    -moz-transform:rotate(90deg);
    -o-transform:rotate(90deg);
    -ms-transform:rotate(90deg);
    transform:rotate(90deg);
    z-index: 0;
}
input[type=range].vHorizon {
    -webkit-appearance: none;
    background-color: pink;
    height: 10px;
    width:200px;

}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    background-color: red;
    width: 20px;
    height: 20px;
}

fiddle <--UPDATED

like image 78
cube Avatar answered Nov 15 '22 03:11

cube