svg+js实现圆弧状时间滑动拖动取值器代码

代码语言:html

所属分类:拖放

代码描述:svg+js实现圆弧状时间滑动拖动取值器代码

代码标签: svg js 圆弧 时间 滑动 拖动 取值器 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
 
<meta charset="UTF-8">
 


 
<style>
@import url("https://fonts.googleapis.com/css2?family=Inter&display=swap");
body
{
 
display: flex;
 
flex-direction: column;
 
justify-content: center;
 
align-items: center;
 
padding: 40px;
 
min-height: 100vh;
 
background-color: #f2f2f3;
 
font-family: "Inter", sans-serif;
 
font-size: 2em;
}

.slider-wrapper {
 
display: flex;
 
justify-content: center;
 
align-items: center;
 
position: relative;
 
width: 12.5em;
 
max-width: 100%;
 
-moz-user-select: none;
 
-webkit-user-select: none;
 
-ms-user-select: none;
 
user-select: none;
}

.slider-input {
 
position: absolute;
 
opacity: 0;
 
pointer-events: none;
}

.slider-thumb {
 
--color: #fff;
 
display: flex;
 
justify-content: center;
 
align-items: center;
 
position: absolute;
 
z-index: 1;
 
left: calc(var(--slider-value) / 100 * (100% - var(--slider-height)) + var(--slider-height) / 2);
 
transform: translate(-50%, -50%);
 
border-radius: 50%;
 
width: 1.25em;
 
height: 1.25em;
 
background-image: linear-gradient(to bottom, #f0f0f2, #d9dade);
 
box-shadow: 0 0.0625em 0.0625em rgba(0, 0, 0, 0.3);
 
-moz-user-select: none;
 
-webkit-user-select: none;
 
-ms-user-select: none;
 
user-select: none;
 
touch-action: none;
 
cursor: pointer;
}
.slider-thumb::before {
 
content: "";
 
position: absolute;
 
border-radius: inherit;
 
width: 68%;
 
height: 68%;
 
background-color: var(--color);
 
box-shadow: inset 0 -8px 4px rgba(0, 0, 0, 0.1);
}

.slider-value-container {
 
display: flex;
 
justify-content: center;
 
align-items: center;
 
column-gap: 0.5em;
 
position: absolute;
 
bottom: 1em;
 
transform: translateY(-100%);
 
border: 1px solid #dbdbe3;
 
border-radius: 50px;
 
padding: 0.25em 0.75em;
 
background-color: #f2f2f3;
 
box-shadow: 0 0.0625em 0.25em rgba(0, 0, 0, 0.1);
 
font-size: 0.5em;
 
font-feature-settings: "tnum";
 
font-variant-numeric: tabular-nums;
 
white-space: nowrap;
 
pointer-events: none;
 
-moz-user-select: none;
 
-webkit-user-select: none;
 
-ms-user-select: none;
 
user-select: none;
}

.slider-value {
 
-moz-user-select: none;
 
-webkit-user-select: none;
 
-ms-user-select: none;
 
user-select: none;
}

.slider-svg {
 
width: 100%;
 
height: 100%;
 
filter: drop-shadow(0 1px 0 #fff);
 
overflow: visible;
}

.slider-svg-path {
 
touch-action: none;
 
cursor: pointer;
}
</style>

 
 
 
</head>

<body >
 
<div class="slider-wrapper">
 
<input class="slider-input" type="range" value="720" max="1440" step="1">
 
<div class="slider-thumb">
   
<div class="slider-value-container">
     
<p class="slider-value">12:00 PM</p>
   
</div>
 
</div>
  <svg class="slider-svg" viewBox="0 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0