当我添加到以下幻灯片的链接时,我能够链接到的唯一链接是最后一张幻灯片,无论我放置什么。有什么方法可以使用这个幻灯片代码并且链接在同一时间正常工作吗?
HTML
<ul class="slides">
<input type="radio" name="radio-btn" id="img-1" checked />
<li class="slide-container">
<div class="slide">
<a href="http://www.google.com"><img src="/wp-content/uploads/slider1.png" style="background-color:red;"/></a>
</div>
<div class="nav">
<label for="img-4" class="prev">‹</label>
<label for="img-2" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-2" />
<li class="slide-container">
<div class="slide">
<a href="http://www.yahoo.com"><img src="/wp-content/uploads/slider2.png" style="background-color:white;"/></a>
</div>
<div class="nav">
<label for="img-1" class="prev">‹</label>
<label for="img-3" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-3" />
<li class="slide-container">
<div class="slide">
<a href="http://stackoverflow.com/"><img src="/wp-content/uploads/slider3.png" style="background-color:yellow;" /></a>
</div>
<div class="nav">
<label for="img-2" class="prev">‹</label>
<label for="img-4" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-4" />
<li class="slide-container">
<div class="slide">
<a href="http://codepen.io/"><img src="/wp-content/uploads/slider4.png" style="background-color:blue;" /></a>
</div>
<div class="nav">
<label for="img-3" class="prev">‹</label>
<label for="img-1" class="next">›</label>
</div>
</li>
<li class="nav-dots">
<label for="img-1" class="nav-dot"></label>
<label for="img-2" class="nav-dot"></label>
<label for="img-3" class="nav-dot"></label>
<label for="img-4" class="nav-dot"></label>
</li>
CSS
.slides {
padding: 0;
width: 980px;
height: 241px;
display: block;
margin: 0 auto;
position: relative;
}
.slides * {
user-select: none;
-ms-user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none;
}
.slides input { display: none; }
.slide-container { display: block; }
.slide {
top: 0;
opacity: 0;
width: 980px;
height: 241px;
display: block;
position: absolute;
transition: all .7s ease-in-out;
}
.slide img {
width: 100%;
height: 100%;
}
.nav label {
width: 40px;
height: 100%;
display: none;
position: absolute;
opacity: 0.5;
z-index: 9;
cursor: pointer;
transition: opacity .2s;
color: #FFF;
font-size: 50pt;
text-align: center;
line-height: 225px;
font-family: "Varela Round", sans-serif;
background-color: rgba(255, 255, 255, .3);
text-shadow: 0px 0px 15px rgb(119, 119, 119);
}
.slide:hover + .nav label { opacity: 0.5; }
.nav label:hover { opacity: 1; }
.nav .next { right: 0; }
input:checked + .slide-container .slide {
opacity: 1;
transition: opacity 1s slide;
}
input:checked + .slide-container .nav label { display: block; }
.nav-dots {
width: 100%;
bottom: 9px;
height: 11px;
display: block;
position: absolute;
text-align: center;
}
.nav-dots .nav-dot {
top: 0px;
width: 10px;
height: 10px;
margin: 0 4px;
position: relative;
border-radius: 100%;
display: inline-block;
background-color: rgba(0, 0, 0, 0.6);
}
.nav-dots .nav-dot:hover {
cursor: pointer;
background-color: rgba(0, 0, 0, 0.8);
}
JS
setInterval(function(){
$(".next:visible").click();}, 5000);
这是我的codepen
感谢。
答案 0 :(得分:0)
z-index
有一个css问题。我已将z-index值10赋予与checked
单选按钮对应的活动幻灯片。
input:checked + .slide-container .slide {
opacity: 1;
z-index: 10;
transition: opacity 1s slide;
}
input:checked + .slide-container .nav label {
display: block;
z-index: 10;
}
但是,您将无法在同一选项卡中访问codepen中除codepen之外的其他站点。而只是在新标签页中打开并查看。
请参阅此fiddle,除非您未在新标签页中打开它们,否则您将无法打开这4个网站中的任何网站。