Toggle开关在Firefox和Safari上看起来不错,但在Chrome上却不行

问题描述 投票:0回答:1

我有一个拨动开关,在Safari(移动版)和Firefox中效果很好,但是在Chrome中,它看起来像html复选框……有什么想法吗?正确呈现时,这是一个非常酷的开关,但是在Chrome浏览器中,我无法正常运行。它看起来像一个拨动开关,每侧都有一个蓝色的小灯……根据开关的位置,如果将开关指向该方向,则蓝色的小灯会亮起。

/* Toggle for WAV/MP3 */
.switch input {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    filter: alpha(opacity=0);
    -moz-opacity: 0;
    opacity: 0;
    z-index: 100;
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
  }

  .switch {
    width: 60px;
    height: 25px;
    position: relative;
    right:-5px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 10px;
  }

  .switch label {
    display: block;
    width: 80%;
    height: 100%;
    position: relative;
    background: #1F2736; /*#121823*/
    background: linear-gradient(#121823, #161d2b);
    border-radius: 30px 30px 30px 30px;
    box-shadow: inset 0 3px 8px 1px rgba(0,0,0,0.5),  inset 0 1px 0 rgba(0,0,0,0.5),  0 1px 0 rgba(255,255,255,0.2);
    -webkit-transition: all .5s ease;
    transition: all .5s ease;
  }

  .switch input ~ label i {
    display: block;
    height: 21px;
    width: 21px;
    position: absolute;
    left: 2px;
    top: 2px;
    z-index: 2;
    border-radius: inherit;
    background: #283446; /* Fallback */
    background: linear-gradient(#36455b, #283446);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),  0 0 8px rgba(0,0,0,0.3),  0 12px 12px rgba(0,0,0,0.4);
    -webkit-transition: all .5s ease;
    transition: all .5s ease;
  }

  .switch label + #spanr {
    content: "";
    display: inline-block;
    position: absolute;
    right: -10px;
    top: 3px;
    width: 18px;
    height: 18px;
    border-radius: 10px;
    background: #283446;
    background: gradient-gradient(#36455b, #283446);
    box-shadow: inset 0 1px 0 rgba(0,0,0,0.2),  0 1px 0 rgba(255,255,255,0.1),  0 0 10px rgba(185,231,253,0),  inset 0 0 8px rgba(0,0,0,0.9),  inset 0 -2px 5px rgba(0,0,0,0.3),  inset 0 -5px 5px rgba(0,0,0,0.5);
    -webkit-transition: all .5s ease;
    transition: all .5s ease;
    z-index: 2;
  }

  /* Toggle */

  .switch input:checked ~ label + #spanr {
    content: "";
    display: inline-block;
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 10px;
    -webkit-transition: all .5s ease;
    transition: all .5s ease;
    z-index: 2;
    background: #b9f3fe;
    background: gradient-gradient(#ffffff, #77a1b9);
    box-shadow: inset 0 1px 0 rgba(0,0,0,0.1),  0 1px 0 rgba(255,255,255,0.1),  0 0 10px rgba(100,231,253,1),  inset 0 0 8px rgba( 61,157,247,0.8),  inset 0 -2px 5px rgba(185,231,253,0.3),  inset 0 -3px 8px rgba(185,231,253,0.5);
  }

  .switch input:checked ~ label i {
    left: auto;
    left: 50%;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),  0 0 8px rgba(0,0,0,0.3),  0 8px 8px rgba(0,0,0,0.3),  inset -1px 0 1px #b9f3fe;
    -webkit-transition: all .5s ease;
    transition: all .5s ease;
  }

  .switch #spanl {
    content: "";
    display: inline-block;
    position: absolute;
    right: 64px;
    top: 3px;
    width: 18px;
    height: 18px;
    border-radius: 10px;
    -webkit-transition: all .5s ease;
    transition: all .5s ease;
    z-index: 2;
    background: #b9f3fe;
    background: gradient-gradient(#ffffff, #77a1b9);
    box-shadow: inset 0 1px 0 rgba(0,0,0,0.1),  0 1px 0 rgba(255,255,255,0.1),  0 0 10px rgba(100,231,253,1),  inset 0 0 8px rgba( 61,157,247,0.8),  inset 0 -2px 5px rgba(185,231,253,0.3),  inset 0 -3px 8px rgba(185,231,253,0.5);
  }

  /* Toggle */

  .switch input:checked ~ #spanl {
    content: "";
    display: inline-block;
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 10px;
    background: #283446;
    background: gradient-gradient(#36455b, #283446);
    box-shadow: inset 0 1px 0 rgba(0,0,0,0.2),  0 1px 0 rgba(255,255,255,0.1),  0 0 10px rgba(185,231,253,0),  inset 0 0 8px rgba(0,0,0,0.9),  inset 0 -2px 5px rgba(0,0,0,0.3),  inset 0 -5px 5px rgba(0,0,0,0.5);
    -webkit-transition: all .5s ease;
    transition: all .5s ease;
  }

#spanrr {
    display: inline-block;
    position: absolute;
    right: -52px;
    top: 4px;
}
#spanll {
    display: inline-block;
    position: absolute;
    right: 90px;
    top: 4px;
}
<div class="switch">
<input type="checkbox" name="toggle" id="qualitytoggle" checked>
<span id="spanll">MP3</span>
<span id="spanl"></span>
<label for="toggle"><i></i></label>
<span id="spanr"></span>
<span id="spanrr">WAV</span>
</div>
css google-chrome select switch-statement toggle
1个回答
0
投票

我找到了解决方案!!!这是我CSS中其他地方的愚蠢语法错误……我忘记了逗号!

GOOD:

。songbuttons:hover,.pdfbutton:hover {}

坏:

。songbuttons:hover .pdfbutton:hover {}

© www.soinside.com 2019 - 2024. All rights reserved.