我有一個圖像滑塊 - 一切工作正常,當我只有4個圖像。當我開始向幻燈片放映中添加圖像時,同時顯示2張照片,因此滑塊不起作用。Pure css滑塊 - 爲什麼圖像以塊形式顯示?
如果我在添加圖像時做錯了什麼,我將不勝感激。
謝謝!
html {
background: radial-gradient(#238dbb, #114476);
height: 100%;
text-align: center;
font-family: Helvetica;
font-size: 3em;
color: #134c7e;
}
input.set {
display: none;
}
#slide1:checked ~ .mask .overflow {
margin-left: 0;
}
#slide2:checked ~ .mask .overflow {
margin-left: -100%;
}
#slide3:checked ~ .mask .overflow {
margin-left: -200%;
}
#slide4:checked ~ .mask .overflow {
margin-left: -300%;
}
#slide5:checked ~ .mask .overflow {
margin-left: -400%;
}
#slides {
margin: 50px auto;
width: 80%;
position: relative;
}
#slides .mask {
width: 90%;
overflow: hidden;
margin: auto;
}
#slides .overflow {
width: 400%;
-webkit-transform: translateZ(0);
-webkit-transition: all 0.5s ease-out;
-moz-transition: all 0.5s ease-out;
-o-transition: all 0.5s ease-out;
transition: all 0.5s ease-out;
}
#slides .slide {
width: 25%;
height: 200px;
line-height: 200px;
float: left;
background: #fff;
}
#controls {
width: 100%;
}
#controls label {
display: none;
width: 5%;
height: 60px;
opacity: 0.3;
position: absolute;
top: 50%;
margin-top: -30px;
cursor: pointer;
background: #000;
}
#controls label:hover {
opacity: 0.8;
}
#slide1:checked ~ #controls label:nth-child(2),
#slide2:checked ~ #controls label:nth-child(3),
#slide3:checked ~ #controls label:nth-child(4),
#slide4:checked ~ #controls label:nth-child(5) {
right: 0;
display: block;
}
#slide2:checked ~ #controls label:nth-child(1),
#slide3:checked ~ #controls label:nth-child(2),
#slide4:checked ~ #controls label:nth-child(3),
#slide5:checked ~ #controls label:nth-child(4) {
left: 0;
display: block;
}
<div id="slides">
<input checked type="radio" name="slider" id="slide1" class="set" />
<input type="radio" name="slider" id="slide2" class="set" />
<input type="radio" name="slider" id="slide3" class="set" />
<input type="radio" name="slider" id="slide4" class="set" />
<input type="radio" name="slider" id="slide5" class="set" />
<div class="mask">
<div class="overflow">
<div class="slide">
<img src="http://static.asiawebdirect.com/m/phuket/portals/phuket-com/homepage/phuket-magazine/freedom-beach/pagePropertiesImage/freedom-beach.jpg">
</div>
<div class="slide">2</div>
<div class="slide">
<img src="http://static.asiawebdirect.com/m/phuket/portals/phuket-com/homepage/phuket-magazine/freedom-beach/pagePropertiesImage/freedom-beach.jpg">
</div>
<div class="slide">
<img src="http://7-themes.com/data_images/out/33/6882876-beach-sunset.jpg">
</div>
<div class="slide">
<img src="http://wallpapercave.com/wp/rt17YTU.jpg">
</div>
</div>
</div>
<div id="controls" onclick="">
<label for="slide1"></label>
<label for="slide2"></label>
<label for="slide3"></label>
<label for="slide4"></label>
<label for="slide5"></label>
</div>
</div>
如果你有五個「寬度:25%」的孩子,這意味着他們將是他們父母的寬度的125%。不管父母的寬度,他們會不會換行? [實施例](https://jsfiddle.net/4m94e5gm/1/) – Santi