简体   繁体   English

如何在洗涤器栏中制作可拖动手柄(div)

[英]How to make a draggable handle (div) in a scrubber bar

I am trying to create and audio scrubber bar using a handle I can drag back and forth to a different part of the music. 我正在尝试使用一个手柄来创建音频擦洗器栏,并可以将其来回拖动到音乐的不同部分。

The item that has to be draggable is the .handle , and .played will follow it. 必须拖动的项是.handle ,并且.played将紧随.played

I made the structure as below: JSFiddle 我做了如下结构: JSFiddle

 .scrubber { width: 300px; position: relative; border: 1px solid rgba(0, 0, 0, 0.8); } .scrubber>.bar { background: transparent; height: 10px; } .scrubber>.buffer { position: absolute; height: 10px; background: rgba(255, 0, 0, 0.2); top: 0; } .scrubber>.played { position: absolute; width:100px; height: 10px; background: red; top: 0; } .scrubber>.played>.handle { float: right; width: 10px; height: 10px; margin-top: 0px; margin-right: -5px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); } 
 <div class="scrubber"> <div class="bar"></div> <div class="buffer"></div> <div class="played"> <div class="handle"></div> </div> </div> 

Any idea how to make it work? 任何想法如何使其工作?

you need to use 你需要使用

<input type="range" />

and stylize it as you need 并根据需要对其进行样式化

codepen link: https://codepen.io/anon/pen/MLZpzg codepen链接: https ://codepen.io/anon/pen/MLZpzg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM