【问题标题】:css not working for range input sliderCSS不适用于范围输入滑块
【发布时间】:2013-04-19 07:57:16
【问题描述】:

我想在“垂直”中显示范围输入滑块。

我使用此代码显示垂直 -webkit-appearance: slider-vertical 它显示滑块但 css 无法正常工作它显示普通输入范围滑块。

谁能帮我怎么做。

这是我的代码

<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;"/>
    <title>How to style an HTML5 range input with CSS</title>
    <style type="text/css" media="screen">
        body {
            font-family: Helvetica, sans-serif;
            margin: 0;
            padding: 10px;
        }
        input[type='range'] {
            -webkit-appearance: slider-vertical !important;
            -webkit-border-radius: 10px;
            -webkit-box-shadow: inset 0 0 5px #333;
            background-color: #157DEC;
            display: block;
            height: 15px;
            left: 10px;
            margin: -100px 0 0 100px;
            position: absolute;
            right: 10px;
        }
        input[type='range']::-webkit-slider-thumb {
            -webkit-appearance:  none !important;
            -webkit-border-radius: 10px;
            background-color: #FFFFFF;
            background-image: -webkit-gradient(circular, left top, left bottom, from(##FFFFFF), to(#AAA));
            border: 1px solid #999;
            height: 33px;
            width: 33px;
        }
        #range {
            display: block;
            font-size: 200%;
            font-weight: bold;
            margin: -58px -12px 107px 4px ;
            text-align: center;
        }
        p {
            position: absolute;
            bottom: 0;
            left: 10px;
            font-size: 10px;
            right: 10px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div id="wrapper">
        <span id="range">0</span>
        <input type=range name=salary min="0" max="5" value="0" step="1" onchange="showValue(this.value)" />


    </div>
    <script type="text/javascript">
        function showValue(newValue) {
            document.getElementById("range").innerHTML=newValue;
        }
    </script>
</body>
</html>

【问题讨论】:

    标签: html css slider range


    【解决方案1】:

    在你的 CSS 中不要太高。你强制到一个固定的维度。

    这是我对你的风格的建议

       body {
            font-family: Helvetica, sans-serif;
            margin: 0;
            padding: 10px;
            overflow:hidden;
        }
        input[type='range'] {
            -webkit-appearance: slider-vertical;/*comment this to see the result*/
            -webkit-border-radius: 10px;
            -webkit-box-shadow: inset 0 0 5px #333;
            background-color: #157DEC;
            display: block;
            /*height: 15px;*/
            left: 10px;
            /*margin: -100px 0 0 100px;*/
            /*position: absolute;*/
            right: 10px;
            margin-top:50px;
        }
        input[type='range']::-webkit-slider-thumb {
            -webkit-appearance:  none !important;
            -webkit-border-radius: 10px;
            background-color: #FFFFFF;
            background-image: -webkit-gradient(circular, left top, left bottom, from(##FFFFFF), to(#AAA));
            border: 1px solid #999;
           /* height: 33px;*/
            width: 33px;
        }
        #range {
            display: block;
            font-size: 200%;
            font-weight: bold;
            margin: -58px -12px 107px 4px ;
            text-align: center;
        }
        p {
            position: absolute;
            bottom: 0;
            left: 10px;
            font-size: 10px;
            right: 10px;
            text-align: center;
        }
    

    这是小提琴的预览:http://jsfiddle.net/QXzLT/

    【讨论】:

      猜你喜欢
      • 2021-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-10
      • 2018-09-22
      • 1970-01-01
      • 2020-04-03
      • 2023-03-17
      相关资源
      最近更新 更多