css实现可拖动平衡滑块选择器代码

代码语言:html

所属分类:拖放

代码描述:css实现可拖动平衡滑块选择器代码,拖动中间竖线试试。

代码标签: css 拖动 平衡 滑块 选择器 代码

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

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

<head>
  <meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.5.0.css">
<style>


*,
*:after,
*:before {
  box-sizing: border-box;
}

body {
  display: flex;
  place-items: center;
  min-height: 100vh;
  font-family:  "Geist Sans", "SF Pro Text", "SF Pro Icons", "AOS Icons", "Helvetica Neue", Helvetica, Arial, sans-serif, system-ui;
  background: hsl(0 0% 6%);
}

body::before {
  --line: hsl(0 0% 95% / 0.15);
  content: "";
  height: 100vh;
  width: 100vw;
  position: fixed;
  background:
    linear-gradient(90deg, var(--line) 1px, transparent 1px 10vmin) 0 -5vmin / 10vmin 10vmin,
    linear-gradient(var(--line) 1px, transparent 1px 10vmin) 0 -5vmin / 10vmin 10vmin;
  -webkit-mask: linear-gradient(-15deg, transparent 30%, white);
          mask: linear-gradient(-15deg, transparent 30%, white);
  top: 0;
  z-index: -1;
  transform: translate3d(0, 0, -100vmin);
}

@layer foundation {
  .control {
    position: relative;
    display: grid;
    place-items: center;
    margin: 0 auto;
  }

  .sr-only {
  	position: absolute;
		width: 1px;
		height: 1px;
		padding: 0;
		margin: -1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
		border-width: 0;
  }

  .control:focus-within,
  .control:hover {
    --active: 1;
  }

  [type="range"] {
    width: 300px;
    opacity: 0;
    height: 60px;
  }

  [type="range"]:hover {
    cursor: -webkit-grab;
  }
  [type="range"]:active {
    cursor: -webkit-grabbing;
  }

  [type=range]:focus-visible {
    outline-offset: 0.25rem;
    outline-color: transparent;
  }

  @property --shift {
  	initial-value: 0;
  	inherits: true;
  	syntax: '<integer>';
  }

  .tooltip {
    font-size: 1rem;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    pointer-events: none;
    transform: translateY(calc(var(--shift, 0) * 50%));
    transition: transform var(--speed) var(--timing);
    z-index: 2;
  }
  @-webkit-keyframes shift {
  	0%, 31%, 61%, 100% { --shift: 0; }
  	32%, 60% { --shift: 1; }
  }
  @keyframes shift {
  	0%, 31%, 61%, 100% { --shift: 0; }
  	32%, 60% { --shift: 1; }
  }

  .tooltip::after,
  .tooltip::before {
    font-variant: tabular-nums;
    position: absolute;
    top: 50%;
    translate: 0 -50%;
    font-weight: bold;
    color: white;
    font-weight: 40;
    font-family: monospace;
  }

  [type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
            appearance: none;
    -webkitappearance: none;
    height: 120px;
    width: 40px;
    margin-top: 0px;
	  opacity: 1;
	}
	[type="range"]::-webkit-slider-runnable-track {
  	-webkit-appearance: none;
	  height: 120px;
	  background: hsl(10 80% 50% / 0.5);
	  margin-top: -60px; /* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
	  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d; 
	}
	[type=range]::-moz-range-track {
	  height: 120px;
	  background: hsl(10 80% 50% / 0.5);
	  margin-top: -60px; /* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
	  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d; 
	}
}


@layer scrolls {
  @property --value {
    initial-value: 0;
    syntax: '<integer>';
    inherits: true;
  }

  @-webkit-keyframes sync {
    to { --value: 100; }
  }

  @keyframes sync {
    to { --value: 100; }
  }

  [type=range] {
    overflow: hidden;
    opacity: 0;
    touch-action: none;
  }

  .control {
    -webkit-animation: sync both linear reverse, shift both linear;
            animation: sync both linear reverse, shift both linear;
    animation-timeline: --thumb;
    animation-range: contain;
  }

  .control__track {
  	--coffee: hsl(24 74% calc(24% + (30% * ((100 - var(--value, 0)) / 100)) / 1) / 0.4);
  	--milk: hsl(0 0% 100% / calc(0.1 + (0.4 * ((100 - var(--value, 0)) / 100))));
  	height: calc(50% + (var(--shift) * 50%));
  	widt.........完整代码请登录后点击上方下载按钮下载查看

网友评论0