HI如何通過將圖像懸停在另一個div中來將圖像懸停在一個div上?
我有5個div。 (div class =「part1」class =「part2」class =「part3」class =「part4」class =「part5」全部浮動到左側,寬度爲20%),因此它們排成一行。
每個div包含2個圖像假設image1的id爲「top」,image2的id爲「bottom」(分別在所有div中)。
現在我要做的就是,我把ID爲「底部」的所有圖像的不透明度爲0,上徘徊像「頂」我改變「底部」不透明度爲1和「頂」不透明度爲0
它的工作很好,直到現在。
現在我想要的是 我想在第1部分與id的第三張圖片假設id =「黃色」。現在
當web負載我想顯示「頂部」 ID圖像在部分1,當用戶將鼠標懸停在部分11d
=「頂部」圖像我想顯示ID =「底部」圖像(直至現在我實現這一目標)
現在,如果用戶將鼠標懸停在第2部分,第三部分,第四部分,PART5我想顯示id爲「黃色」的圖像部分1
我嘗試使用僞選擇+,〜等等,但很快我意識到,他們只有當一個div分別在其他div或內部的父div。但在我的情況下,第一部分是在第二部分之前......所以我不能改變順序。附:我知道它可能與JS jQuery,但我不想使用它們。
一些代碼
< div class="part1">
<img1 id="top"></img> colored image with happy child
<img2 id="bottom"></img> yellow image with sad child
<img3></img> plain yellow image
</div>
< div class="part2">
<img1 id="top"></img> colored image with happy child
<img2 id="bottom"></img> yellow image with sad child
</div>
<div class="part3">
<img1 id="top"></img> colored image with happy child
<img2 id="bottom"></img> yellow image with sad child
</div>
< div class="part4">
<img1 id="top"></img> colored image with happy child
<img2 id="bottom"></img> yellow image with sad child
</div>
< div class="part5">
<img1 id="top"></img> colored image with happy child
<img2 id="bottom"></img> yellow image with sad child
</div>
現在我要顯示在第1部分黃色ID形象,當我在part2- PART5 即懸停我不想顯示圖像與id頂部和底部分別只在第1部分只是圖像與黃色
你需要一些js代碼 – abidibo 2015-03-19 09:23:34
@abidibo我知道,但只有純粹的HTML CSS是可能的嗎? – 2015-03-19 09:26:53
@AmmarUlHassan:根據我對你之後的理解,js將是採取的方法(即使css是可能的,這將是越野車和非常不潔的代碼)。堅持他們所做的事情。 - 並且js是爲此製作的。 – jbutler483 2015-03-19 09:28:55