zoukankan      html  css  js  c++  java
  • 滑动条

     

      

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    body{
    	margin:50px; ; 
    }
    .scale_panel{
    	font-size:12px;
    	color:#999;
    	200px;
    	position:absolute; 
    	line-height:18px; 
    	left:60px;
    	top:-0px;
    }
    .scale_panel .r{
    	float:right;
    }
    .scale span{
    	background:url(scroll.gif) no-repeat; 
    	8px;
    	height:16px; 
    	position:absolute; 
    	left:-2px;
    	top:-5px;
    	cursor:pointer;
    }
    .scale{ background-repeat: repeat-x; background-position: 0 100%; background-color: #E4E4E4; border-left: 1px #83BBD9 solid;   200px; height: 3px; position: relative; font-size: 0px; border-radius: 3px; }
    .scale div{ background-repeat: repeat-x; background-color: #3BE3FF;  0px; position: absolute; height: 3px;  0; left: 0; bottom: 0; }
    li{
    	font-size:12px;
    	line-height:50px;
    	position:relative; 
    	height:50px; 
    	list-style:none;
    }
    </style>
    </head>
    <body>
    <ul>
     <li>red <span id="title">0</span>
    <div class="scale_panel">
    	<span class="r">100</span>0
    	<div class="scale" id="bar">
    		<div></div>
    		<span id="btn"></span>
    	</div> 
    </div> 
     </li>
     <li>green <span id="title2">0</span>
    <div class="scale_panel">
    	<span class="r">100</span>0
    	<div class="scale" id="bar2">
    		<div></div>
    		<span id="btn2"></span>
    	</div> 
    </div> 
     </li>
     <li>blue <span id="title3">0</span>
    <div class="scale_panel">
    	<span class="r">100</span>0
    	<div class="scale" id="bar3">
    		<div></div>
    		<span id="btn3"></span>
    	</div> 
    </div> 
     </li>
    </ul>
    </body>
    <script>
    scale=function (btn,bar,title){
    	this.btn=document.getElementById(btn);
    	this.bar=document.getElementById(bar);
    	this.title=document.getElementById(title);
    	this.step=this.bar.getElementsByTagName("DIV")[0];
    	this.init();
    };
    scale.prototype={
    	init:function (){
    		var f=this,g=document,b=window,m=Math;
    		f.btn.onmousedown=function (e){
    			var x=(e||b.event).clientX;
    			var l=this.offsetLeft;
    			var max=f.bar.offsetWidth-this.offsetWidth;
    			g.onmousemove=function (e){
    				var thisX=(e||b.event).clientX;
    				var to=m.min(max,m.max(-2,l+(thisX-x)));
    				f.btn.style.left=to+'px';
    				f.ondrag(m.round(m.max(0,to/max)*100),to);
    				b.getSelection ? b.getSelection().removeAllRanges() : g.selection.empty();
    			};
    			g.onmouseup=new Function('this.onmousemove=null');
    		};
    	},
    	ondrag:function (pos,x){
    		this.step.style.width=Math.max(0,x)+'px';
    		this.title.innerHTML=pos+'%';
    	}
    }
    new scale('btn','bar','title');
    </script>
    </html>
    

      

  • 相关阅读:
    在ASP.NET 2.0中使用WebParts
    Asp.net生成静态页面原理
    提高ASP.Net应用程序性能的十大方法
    Web2.0之Tag标签原理实现浅析
    ASP.NET 2.0中的URL映射
    动态加载控件UserControl到页面上:视图状态问题
    C#自动登录网页浏览页面 抓取数据
    .NET Framework 类库提供的命名空间
    一个用于热部署的框架设想
    重构如何进行?
  • 原文地址:https://www.cnblogs.com/SharkChilli/p/8043385.html
Copyright © 2011-2022 走看看