650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8D/08/wKioL1iDLBmD213eAAAGLzbDBnE070.png-wh_500x0-wm_3 -wmp_4-s_2351492165.png "title=" 2017-01-21_173802.png "alt=" Wkiol1idlbmd213eaaaglzbdbne070.png-wh_50 "/>
HTML section:
<!--progress bar s-->
<div class= "M_i_c_con" >
<div id= "Dragout" class= "m_i_c_out" ><div id= "Dragbar" class= "m_i_c_in" ></div></div>
<div id= "dragbtn" class= "M_i_c_drag" >0%</div>
</div>
<!--progress bar e-->
CSS section:
. m_i_c_con{position:relative; height:55px;}
. m_i_c_out{Position:absolute; Overflow:hidden; left: -1px; top:8px; box-shadow:0 1px 1px #e3e3e3; width:100%; height: 12px; border:1px solid #e7e7e7; border-radius:5px; Background-color: #fff;}
. m_i_c_in{height:18px; width:0%; Background-color: #C1C1C1;}
M_i_c_drag{position:absolute; z-index:100; left:0%; top:0px; width:46px; height:56px; Margin-left: -8%; line-height : 76px; Background:url (.. /images/tuodongqiu.png) no-repeat Center 0px; background-size:26px; Text-align:center;color: #8a8b8b; font-size:15px;}
JS section:
$ (function () {
var opts = {};
$ (' #dragBtn '). Bind (' Touchstart ', function (e) {
E.preventdefault ();
Opts.startx = E.originalevent.changedtouches[0].pagex;
Opts.offsetleft = parsefloat ($ (this). CSS (' left '));
});
$ (' #dragBtn '). Bind (' Touchmove ', function (e) {
E.preventdefault ();
Opts.moveendx = E.originalevent.changedtouches[0].pagex;
OPTs. X = Opts.moveendx-opts.startx;
Opts.full = parsefloat ($ (' #dragOut '). width ());
Opts.newleft = opts. X + opts.offsetleft;
Opts.perval = opts.newleft/opts.full * 100;
if (opts.newleft <= opts.full && opts.newleft >= 0) {
$ (' #dragBar '). Width (opts.perval.toFixed (0) + '% ');
$ (this). css ({' Left ': opts.perval.toFixed (0) + '% '});
$ (this). Text (opts.perval.toFixed (0) + '% ');
}
});
$ (' #dragBtn '). Bind (' Touchend ', function (e) {
E.preventdefault ();
opts = {};
});
Mobile custom-pleasing slider bar