当前位置:   article > 正文

刻度尺效果_前端画一个标尺

前端画一个标尺

废话不多说,我们直接上代码

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta name="format-detection" content="telephone=no"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="cache-control" content="no-cache">
<meta name="browsermode" content="application">
<meta name="x5-page-mode" content="app">
<meta name="msapplication-tap-highlight" content="no">
<title>刻度尺效果</title>
<style>
*{
    padding: 0;
    margin: 0;
}
.scale{
    position: relative;
    width: 100%;
    padding: 10px 0;
}
.scale em{
    position: absolute;
    top: 50%;
    display: block;
    width: 36px;
    height: 28px;
    font-size: 20px;
    font-style: normal;
    line-height: 28px;
    margin-top: -14px;
}
.scale em.blue{
    left: 10px;
    color: #4359aa;
}
.scale em.red{
    right: 10px;
    color: #ff3300;
}
form{
    padding: 0 60px;
}
input[type="range"]{
    width: 100%;
    height: 9px;
    background: url(images/int-risk-level-bar.png) no-repeat center;
    background-size: 100% 9px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    -webkit-box-shadow: 2px 2px 3px 0 rgba(11,18,73,0.4);
    box-shadow: 2px 2px 3px 0 rgba(11,18,73,0.4);
    -webkit-appearance: none;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
    background: #ffffff;
    -webkit-border-radius: 50%;
    border-radius: 50%;
    -webkit-box-shadow: 0 0 3px 2px rgba(73,53,11,0.2);
    box-shadow: 0 0 3px 2px rgba(73,53,11,0.2);
    -webkit-appearance: none;
    cursor: default;
}   
output{
    position: absolute;
    left: 50%;
    bottom: -40px;
    display: block;
    height: 40px;
    width: 40px;
    font-size: 16px;
    color: #222222;
    text-align: center;
    line-height: 40px;
    background: yellow;
    margin-left: -20px;
}
</style>
</head>
<body>
    <div class="scale">
        <em class="blue">0</em>
        <form oninput="scaleShow.value=parseInt(scale.value)">
            <input type="range" id="scale"/>
            <output name="scaleShow" for="scale" ></output>
        </form>
        <em class="red">100</em>
    </div>

</body>
</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96

实现效果:
这里写图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/563549
推荐阅读
相关标签
  

闽ICP备14008679号