在悬停任何元素时会改变所有元素
我有3个要素:SVG,P和P
HTML代码
<svg xmlns="http://www.w3.org/2000/svg" class="absolute top-1/4 left-12" width="335.312" height="119.152" viewBox="0 0 335.312 119.152">
<path id="Path_2" data-name="Path 2" d="M334.1,0H58.861L0,58.861l58.861,58.861H334.1Z" transform="translate(0.707 0.723)" fill="#ed3430" stroke="rgba(0,0,0,0)" stroke-width="1"/>
</svg>
<p class="absolute text-white top-28 left-24 text-4xl font-extrabold">Text A</p>
<p class="absolute text-white top-52 w-40 font-extrabold italic text-center left-20">Some text...</p>
CSS代码
svg, p {
transition: transform 1s;
}
svg:hover, p:hover {
transform: translate(-30px, 0px);
}
当我悬停在这3个元素中时,我想转换所有这3个元素。当前,如果我悬停了P元素,则只有特定的P元素会转换,而其他2个元素不受影响。
更新 - 添加了视频
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望他们所有人都同时做同样的事情,则可以将它们包裹在容器中,而不是试图通过它们迭代并让它们所有人相互合作。
If you want them all to do the same thing at the same time, you could wrap them in a container instead of trying to iterate through them and get them all to cooperate with each other.