gpt4 book ai didi

css - 转换一个div而不转换里面的图标

转载 作者:行者123 更新时间:2023-12-02 04:39:12 25 4
gpt4 key购买 nike

我正在尝试使用 CSS 转换属性在悬停时转换 div

我有转换做我想做的,但不幸的是它应用转换(逻辑上我猜)到 div 的内容我只想应用转换 div 但不是底层内容(在本例中为图标)。

我在这里看到了一些方法,包括对图标应用反向过渡,但当我这样做时,效果会成倍增加。

这里是 my code :

.MsgBtnIcon {
position: fixed;
bottom: 0px;
right: 7px;
padding: 0px;
}
#transDemo2 div {
display: block;
position: fixed;
bottom: 0px;
right: 0px;
background-color: #03A9F4;
width: 75px;
height: 75px;
text-align: center;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
#transDemo2 div:hover,
#transDemo2 div.hover_effect {
-webkit-transform: rotate(360deg) scale(2, 2) translateX(-19px) translateY(-19px);
-moz-transform: rotate(360deg) scale(2, 2) translateX(-19px) translateY(-19px);
-ms-transform: rotate(360deg) scale(2, 2) translateX(-19px) translateY(-19px);
transform: rotate(360deg) scale(2, 2) translateX(-19px) translateY(-19px);
}
<script src="https://use.fontawesome.com/353bc64522.js"></script>
<div id="transDemo2">
<div class="hover">
<i class="fa fa-plus fa-4x MsgBtnIcon" aria-hidden="true"></i>
</div>
</div>

最佳答案

您可以通过将 MsgBtnIcon 移动到悬停 div 的子元素并添加 pointer-events: none 来完成此操作。

Updated fiddle example

.MsgBtnIcon {
position: fixed;
bottom: 0px;
right: 7px;
padding: 0px;
pointer-events: none;
}
#transDemo2 div {
display: block;
position: fixed;
bottom: 0px;
right: 0px;
background-color: #03A9F4;
width: 75px;
height: 75px;
text-align:center;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;

}

#transDemo2 div:hover, #transDemo2 div.hover_effect {
-webkit-transform:rotate(360deg) scale(2,2) translateX(-19px) translateY(-19px);
-moz-transform:rotate(360deg) scale(2,2) translateX(-19px) translateY(-19px);
-ms-transform:rotate(360deg) scale(2,2) translateX(-19px) translateY(-19px);
transform:rotate(360deg) scale(2,2) translateX(-19px) translateY(-19px);
}
<script src="https://use.fontawesome.com/353bc64522.js"></script>

<div id="transDemo2">
<div class="hover"></div>
<i class="fa fa-plus fa-4x MsgBtnIcon" aria-hidden="true"></i>
</div>

关于css - 转换一个div而不转换里面的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38878173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com