CSS加号选择器的CSS替代方案?

时间:2015-12-28 22:28:52

标签: javascript jquery html css

我正在试图弄清楚是否有一个CSS替代使用CSS加号选择器,以便我的css滑块可以在不支持加号选择器的旧浏览器中使用。我正在寻找一种CSS替代方案。但有没有办法检测不支持CSS加号选择器的浏览器,并使用Jquery替代方案,我想知道如何解决这个问题。

以下是我的Jsfiddle示例https://jsfiddle.net/2hmb60w0/

的链接

HTML

<form class="sliders">
    <input type="radio" name="slider-choice" id="first-slider" checked />
    <div class="slider-container">
        <div class="slider">
            <p>Some Random Text...</p>
        </div>
        <div class="nav">
            <label for="second-slider" class="prev"></label>
            <label for="second-slider" class="next"></label>
        </div>
    </div>

    <input type="radio" name="slider-choice" id="second-slider" />
    <div class="slider-container">
        <div class="slider">
            <p>Even Some More Random Text...</p>
        </div>
        <div class="nav">
            <label for="first-slider" class="prev"></label>
            <label for="first-slider" class="next"></label>
        </div>
    </div>
</form>

CSS

.sliders {
    width: 600px;
    position: relative;
}

.sliders input{ 
    display: none; 
}

.slider {
    position: absolute;
    opacity: 0;
    width: 600px;
    transform: scale(0);
    transition: all .6s ease-in-out;
}

.nav label {
  margin-top: 65px;
    width: 85px;
    display: none;
    position: absolute;
    opacity: 0;
    cursor: pointer;
    transition: opacity .2s;
    color: black;
    font-size: 6em;
    text-align: center;
    background-color: rgba(100, 100, 100, .6);
}

.slider:hover + .nav label, .slider:focus + .nav label{ 
    opacity: 0.6; 
}

.nav label:hover, .nav label:focus{ 
    opacity: 1; 
}

.nav .next{ 
    right: 0;
}

.prev:before{
    content: '\2770';
}

.next:before{
    content: '\2771';
}

input:checked + .slider-container .slider{
    opacity: 1;
    transform: scale(1);
    transition: opacity 2s ease-in-out;
}

input:checked + .slider-container .nav label{ 
    display: block; 
}

p{
    padding: 100px 20px;
    width: 560px;
    text-align: center;
    background: #dae1ef;
}

1 个答案:

答案 0 :(得分:0)

如果您真的想支持IE8(不支持+选择器),我建议您使用polyfill