I am trying to create an input[type=range]
element which moves vertically instead of horizontally. I would also like to customize it with my own CSS. Also, I would like it to scale to fit its parent's dimensions rather than having to explicitly declare its dimensions. Is this possible in any modern browser?
My understandings:
- I can use
-webkit-appearance: none
to apply custom CSS toinput[type=range]
- I can use
-webkit-appearance: slider-vertical
to create a vertical slider with a box model that accurately reflects its position. - I can use
transform: rotate(90deg)
to create a vertical slider with a box model which does not accurately reflect its position.
As such, it would appear that my goal isn't possible with today's browsers. Is that correct?
Here's a JSFiddle with my best effort. I am able to achieve two-thirds of my goal, but need to explicitly invert the height/width of the parent and apply that to the input[type=range]
element.
Here is the accompanying code:
<div class='parent'>
<input type="range" class='vertical-range' />
</div>
<br />
<div class='parent'>
<input type="range" class='vertical-range fixed' />
</div>
.parent {
width: 20px;
height: 100px;
background-color: blue;
margin: 50px;
}
.vertical-range {
-webkit-appearance: none;
transform: rotate(90deg);
height: 100%;
width: 100%;
background-color: green;
margin: 0;
}
.fixed {
width: 100px;
height: 20px;
-webkit-transform-origin: 0 0;
margin-left: 20px;
}
and here is another question I found which is very similar, but was not answered appropriately due to lack of initial instructions