的jsfiddle這裏:https://jsfiddle.net/br84z1Lj/CSS圖片交換一次一個
懸停,兩個圖像交換,而不只是一個。如果我結束「swapMe」的div並重新啓動它以用於下一個圖像,它會將下一個圖像放在下一行,而不是保持一致。我完全停留在獲取只有一個圖像改變懸停而不是兩個!
CSS
@charset "utf-8";
/* CSS Document */
#thumbs {
width: 460px;
margin-top: 90px;
margin-left: auto;
margin-right: auto;
text-align: justify;
-ms-text-justify: distribute-all-lines;
text-justify: distribute-all-lines;
}
#thumbs a {
vertical-align: top;
display: inline-block;
*display: inline;
zoom: 1;
}
.stretch {
width: 100%;
display: inline-block;
font-size: 0;
line-height: 0
}
.swapMe img {
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
.swap1,
.swapMe:hover .swap2 {
-webkit-opacity: 1;
-moz-opacity: 1;
opacity: 1;
}
.swapMe:hover .swap1,
.swap2 {
-webkit-opacity: 0;
-moz-opacity: 0;
opacity: 0;
}
HTML
<body>
<div id="thumbs">
<div class="swapMe">
<a id="single_image1" href="#"><img src="http://dummyimage.com/200/000000/fff" class="swap1" style="position: absolute" height="150" width="188" alt="" />
<img src="http://dummyimage.com/200/d100d1/fff" height="150" width="188" class="swap2">
</a>
<a id="single_image2" href="#"><img src="http://dummyimage.com/200/000000/fff" class="swap1" style="position: absolute" height="150" width="188" alt="" />
<img src="http://dummyimage.com/200/d100d1/fff" height="150" width="188" class="swap2">
</a>
<span class="stretch"></span>
</div>
</div>
</body>
</html>
這是你想完成什麼? https://jsfiddle.net/br84z1Lj/1/ – Berdesdan