【问题标题】:How do I stop the checkbox appearing, so it is slider only如何停止出现复选框,所以它只是滑块
【发布时间】:2015-06-05 19:16:29
【问题描述】:

我在这里使用滑块 3:

http://cssdeck.com/labs/css-checkbox-styles

这是“开/关”滑块,我复制了 HTML 和 CSS。一切正常,但是在我的网页上,“复选框”以及“开/关”滑块仍然可见,请参阅:

http://i.imgur.com/n7Pbitj.jpg

我使用的 CSS 是:

/* SLIDE THREE */
.slideThree {
    width: 80px;
    height: 26px;
    background: #333;
    margin: 20px auto;

    -webkit-border-radius: 50px;
    -moz-border-radius: 50px;
    border-radius: 50px;
    position: relative;

    -webkit-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
    -moz-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
    box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
}

.slideThree:after {
    content: 'OFF';
    font: 12px/26px Arial, sans-serif;
    color: #000;
    position: absolute;
    right: 10px;
    z-index: 0;
    font-weight: bold;
    text-shadow: 1px 1px 0px rgba(255,255,255,.15);
}

.slideThree:before {
    content: 'ON';
    font: 12px/26px Arial, sans-serif;
    color: #00bf00;
    position: absolute;
    left: 10px;
    z-index: 0;
    font-weight: bold;
}

.slideThree label {
    display: block;
    width: 34px;
    height: 20px;

    -webkit-border-radius: 50px;
    -moz-border-radius: 50px;
    border-radius: 50px;

    -webkit-transition: all .4s ease;
    -moz-transition: all .4s ease;
    -o-transition: all .4s ease;
    -ms-transition: all .4s ease;
    transition: all .4s ease;
    cursor: pointer;
    position: absolute;
    top: 3px;
    left: 3px;
    z-index: 1;

    -webkit-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.3);
    -moz-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.3);
    box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.3);
    background: #fcfff4;

    background: -webkit-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
    background: -moz-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
    background: -o-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
    background: -ms-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
    background: linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfff4', endColorstr='#b3bead',GradientType=0 );
}

.slideThree input[type=checkbox]:checked + label {
    left: 43px;
}

我使用的 HTML 是:

<!-- Slide THREE -->
<div class="slideThree">    
    <input type="checkbox" value="None" id="slideThree" name="check" />
    <label for="slideThree"></label>
</div>

感谢您的帮助。

谢谢

【问题讨论】:

  • 我们将需要在浏览器中呈现的 HTML 和您的代码来提供帮助 :)
  • 我现在提供代码:)

标签: javascript jquery html css checkbox


【解决方案1】:

<style> .slideThree input[type=checkbox] {
  visibility: hidden;
}
</style>

【讨论】:

    【解决方案2】:

    使用 CSS:

    .yourSliderClassHere input[type=checkbox] {
      visibility: hidden;
    }
    

    在您提到的网站上查看源代码。

    【讨论】:

    • 嘿,我添加了:.sliderThree input[type=checkbox] { visibility: hidden; } 仍然显示复选框:(
    • 错字?滑动 滑块?
    • 哎呀 :( 谢谢你的帮助 我很感激 ! :)
    猜你喜欢
    • 2016-01-02
    • 1970-01-01
    • 2016-06-27
    • 2020-05-13
    • 1970-01-01
    • 2012-01-24
    • 1970-01-01
    • 2016-05-13
    • 1970-01-01
    相关资源
    最近更新 更多