AudioHTML/test.html

114 lines
2.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
#box {
width: 40px;
height: 430px;
border: 1px solid #000;
margin: 300px;
position: relative;
}
#box1 {
width: 40px;
height: 00px;
background: green;
position: absolute;
}
#span1 {
height: 30px;
width: 60px;
background: green;
display: block;
border-radius: 10px;
position: absolute;
left: -10px;
}
p {
position: absolute;
width: 200px;
height: 40px;
top: 50px;
text-align: center;
line-height: 40px;
font-size: 32px;
}
input[type=range]::-webkit-slider-runnable-track{
-webkit-appearance: none;/*清除系统默认样式*/
width: 16px;/*拖动块宽度*/
background: #cccccc;/*拖动块背景*/
}
input[type=range]{
writing-mode: bt-lr; /*for IE */
-webkit-appearance: slider-vertical; /* for chrome */
width: 10px;
height: 200px;
padding: 0 5px;
}
</style>
</head>
<body>
<input type="range" orient="vertical" min="0" max="100" />
<div id="box">
<div id="box1">
<span id="span1">
</span>
</div>
<div>
<p id="p1"></p>
</div>
</div>
<script type="text/javascript">
var Span = document.getElementById("span1");
var Box = document.getElementById("box");
var Box1 = document.getElementById("box1");
var P1 = document.getElementById("p1");
Span.onmousedown = function (e) {
var evt = e || event;
var x = evt.offsetX;
var y = evt.offsetY;
console.log(x)
console.log(y)
//console.log("Aa")
Box.onmousemove = function (e) {
var evt = e || event;
Span.style.top = evt.clientY - Box.offsetTop - x + "px";
if (evt.clientY - Box.offsetTop - x <= 0) {
Span.style.top = "0px";
}
if (evt.clientY - Box.offsetTop - x >= 400) {
Span.style.top = "400px";
}
//console.log(Span.offsetLeft);
P1.innerHTML = "音量:" + Math.floor(Span.offsetTop / 4);
Box1.style.height = Span.offsetTop + "px";
}
document.onmouseup = function () {
//Box1.style.width=evt.offsetX+"px";
Box.onmousemove = null;
}
}
</script>
</body>
</html>