How to handle style on input=range in jquery mobile?
I want to style the html5 input type 'range'. I am trying to create a mobile website using jquerymobile, but having a bit trouble on styling it in the right way.
I want to have two labels, one at each end of the range selecter, and want the 'pen' to be a black thin stroke.
Right now I have something l开发者_运维百科ike this
<label for="slider">None</label>
<input type="range" name="slider" id="slider" value="0" min="0" max="100" />
<label for="slider" style="text-align: right;">Many</label>
I found the solution by myself.
<style type="text/css" media="screen">
/* Hide text-field*/
#slider {
display: none;
}
div.ui-slider {
width: 90%;
}
label.ui-block-right{
text-align: right;
float: right;
}
.min-width-480px div.ui-slider {
width: 90%;
}
.min-width-480px label.ui-slider {
width: 50%;
}
/* Slider is displayed as a thin stroke */
.ui-slider .ui-slider-handle {
width:2px;
height:30px;
background:url(images/slider-picker.gif) repeat-y; overflow: hidden;
position:absolute;
border-style:none;
margin-left: 0px;
margin-top: -15px;
}
</style>
And the HTML
<div data-role="fieldcontain">
<input type="range" name="slider" id="slider" value="0" min="0" max="100" />
<div class="ui-grid-a" >
<div class="ui-block-a"><label for="slider">None</label></div>
<div class="ui-block-b"><label class="ui-block-right" for="slider">Many</label></div>
</div>
</div>
精彩评论