vue实现多种滑块刻度效果代码
代码语言:html
所属分类:表单美化
代码描述:vue实现多种滑块刻度效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { background: #434d5a; padding: 20px; font-family: "Heebo", sans-serif; color: white; } .slider-pips { position: relative; margin: 30px 0; min-height: 40px; color: #8e9cad; font-size: 12px; } .slider-pips__range { width: 100%; -webkit-appearance: none; -moz-appearance: none; appearance: none; height: 4px; display: inline-block; background: transparent; position: absolute; left: 0; right: 0; top: 0; } .slider-pips__range::-webkit-slider-runnable-track { -webkit-appearance: none; appearance: none; position: relative; background: #8e9cad; height: 4px; border-radius: 4px; } .slider-pips__range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; position: relative; width: 12px; height: 12px; background: #6ef4a4; box-shadow: 0 0 0 2px #434d5a; border-radius: 100%; -webkit-transform: translateY(-4px); transform: translateY(-4px); z-index: 1; } .slider-pips__range:focus, .slider-pips__range:focus::-webkit-slider-runnable-track { outline: none; } .slider-pips__range-selection { position: absolute; top: 0px; height: 4px; background: #6ef4a4; border-radius: 3px; transition: all 0.2s ease-out; } .slider-pips__pips, .slider-pips__floats { position: relative; list-style: none; margin: 0 6px; } .slider-pips__pips { top: 12px; } .slider-pips__pip { position: absolute; top: -5px; left: 0; width: 1px; height: 6px; background: currentColor; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; transition: all 0.5s ease; cursor: pointer; } .slider-pips__pip:hover { color: white; } .slider-pips__pip--selected { color: #86f6b3; height: 10px; transition: all 0.05s ease; } .slider-pips__pip--selected--2 { color: #e69ffa; } .slider-pips__pip--selected--3 { color: #f59d71; } .slider-pips__pip--selected--4 { color: #33d5ff; } .slider-pips__label { position: absolute; left: 50%; top: 100%; -webkit-transform: translate(-50%, 0px); transform: translate(-50%, 0px); padding: 3px; } .slider-pips__label--hidden { display: none; } .slider-pips__float { position: absolute; top: -20px; -webkit-transform: translateX(-15px); transform: translateX(-15px); width: 30px; text-align: center; pointer-events: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; z-index: 1; } .slider-pips__float--2 { z-index: 2; } .slider-pips__float--3 { z-index: 3; } .slider-pips__float--4 { z-index: 4; } .slider-pips__range--2::-webkit-slider-thumb { z-index: 2; } .slider-pips__range--2.slider-pips__range::-webkit-slider-thumb { background: #d96ff7; } .slider-pips__range--3::-webkit-slider-thumb { z-index: 3; } .slider-pips__range--3.slider-pips__range::-webkit-slider-thumb { background: #f27c41; } .slider-pips__range--4::-webkit-slider-thumb { z-index: 4; } .slider-pips__range--4.slider-pips__range::-webkit-slider-thumb { background: #00cbff; } .huge.slider-pips { margin-top: 30px; } .huge.slider-pips ::-webkit-slider-thumb { height: 15px; margin-top: -2px; width: 26px; border-radius: 3px; } .huge.slider-pips .slider-pips__pip { height: 5px; width: 2px; transition-duration: 1s; } .huge.slider-pips .slider-pips__pip:nth-child(5n + 1) { height: 9px; } .huge.slider-pips .slider-pips__pip--selected { height: 12px !important; transition: none; } .huge.slider-pips .slider-pips__float { top: -4px; color: black; } .huge.slider-pips .slider-pips__pips, .huge.slider-pips .slider-pips__floats { margin: 0 13px; } .slider-pips.gradient .slider-pips__range-selection { background: linear-gradient(90deg, #6ef4a4 40%, #d96ff7 60%); } </style> </head> <body> <div id="app"> <slider-pips :min="0" :max="100" :step=5 labels :values="[5]"></slider-pips> <slider-pips :min="-20" :max="20" :step=2.5 labels range :values="[-10]"></slider-pips> <slider-pips :min="-17" :max="17" :step=1 :values="sliderValues" floats></slider-pips> <slider-pips class="gradient" :min="-30" :max="30" :step=3 :values="sliderValues" range labels></slider-pips> <slider-pips :min="-50" :max="50" :step=10 :values="hugeValues" labels></slider-pips> <slider-pips class="huge" :min="-50" :max="50" :step=1 :values="hugeValues" floats></slider-pips> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vue@2.6.1.js"></script> <script > Vue.component("SliderPips", { template: "\n <div class=\"slider-pips\">\n \n <input v-for=\"(value, index) in vals\"\n :key=\"'range' + index\" \n class=\"slider-pips__range\" \n :class=\"[ 'slider-pips__range--' + (index + 1) ]\"\n type=\"range\" :min=\"min\" :max=\"max\" :s.........完整代码请登录后点击上方下载按钮下载查看
网友评论0