码上敲享录 > HTML+CSS实战 > css拖动滑动条改变数字

css拖动滑动条改变数字

上一章章节目录下一章 2020-10-19已有1621人阅读 评论(0)

下面是html完整页面,直接复制运行即可才好看效果:

<!DOCTYPE html>

<html lang="zh" phone="1">

<head>

   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

   <title>滑动条</title>


   <meta http-equiv="X-UA-Compatible" content="IE=edge">

   <meta name="mobile-web-app-capable" content="yes">

   <meta name="apple-mobile-web-app-capable" content="yes">

   <meta name="apple-mobile-web-app-status-bar-style" content="default">

   <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">

   <meta name="theme-color" content="#09924b">

   <meta name="description" content="">

<style>

 input[type="range"] {

 -webkit-appearance: none;

 background-color: #bdc3c7;

 width: 300px;

 height: 5px;

 border-radius: 5px;

 margin: 0 auto;

 outline: 0;

}

input[type="range"]::-webkit-slider-thumb {

 -webkit-appearance: none;

 background-color: #49a9ee;

 width: 20px;

 height: 20px;

 border-radius: 50%;

 border: 2px solid white;

 cursor: pointer;

 transition: 0.3s ease-in-out;

}

input[type="range"]::-webkit-slider-thumb:hover {

 background-color: white;

 border: 2px solid #49a9ee;

}

input[type="range"]::-webkit-slider-thumb:active {

 transform: scale(1.6);


}

</style>

</head>

<body>

<div>

<span class="value"></span>

<input type="range" min="0" max="100" step="1" value="10"></div>

</body>

<script type="text/javascript">

var elem = document.querySelector('input[type="range"]');

var target = document.querySelector('.value');

target.innerHTML = elem.value;

var rangeValue = function(){

 var newValue = elem.value;

 target.innerHTML = newValue;

}

elem.addEventListener("input", rangeValue);

</script>

</html>


0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交