不能动画兄弟元素[重复]

问题描述 投票:0回答:1

好吧,我有div有3个元素:

<div> 
    <img src="http://localhost/images/4.png" alt="alt 4" class="background">
    <img src="http://localhost/images/4_icon.png" alt="alt 4" class="icon">
    <p>
        bla bla
    </p>
</div>

和css如:

.icon:hover ~ .background {
    transform: scale(1.2)
}

但不知道为什么,它不起作用。

css jquery-animate element siblings
1个回答
0
投票

只需使用background元素切换图标即可。代字号仅适用于下一个元素。见下面的例子。另一个解决方案是使用js。

<div> 
    <img src="http://localhost/images/4_icon.png" alt="alt 4" class="icon">
    <img src="http://localhost/images/4.png" alt="alt 4" class="background">
    <p>
        bla bla
    </p>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.