如何通过将鼠标悬停在其他div图像上来将div图像更改为其他图像?

时间:2015-10-23 15:18:56

标签: html css image hover transition

如何通过将鼠标悬停在另一个div中的图像(" pic1")上,将div图像(picturemain.png)更改为其他图像(例如" pic1") ? 纯css首选。

<div class="allSetupOne">
    <div class="mainIMG">
        <img id="main1" src="picturemain.png">
    </div>

    <div class="otherAngles">
        <img id="pic1" src="pictures/gtemp1.png">
        <img id="pic2" src="pictures/gtemp2.png">
        <img id="pic3" src="pictures/gtemp3.png">
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

See this answer

HTML

<div id="a">
    <img src="im" />
    <img class="first" src="im1" />
    <img class="second" src="im2" />    
</div>​​​​​


CSS

#a img.second,
#a img.first:hover ~ img.second {
    display: none;
}

#a img:hover ~ img.first {
    display: none;
}

#a img:hover ~ img.second {
    display: inline-block;
}​