I am attempting to transform a div on hover using the CSS transform properties.
I have the transform doing what I want, but unfortunately its applying the transform (logically I guess), to the contents of the div I want to just apply the transform the div but not the underlying content (an Icon in this case).
I have seen a few methods on here, including applying the reverse transition to the icon, but when I did that it just multiplied the effect.
Here is 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>
You can accomplish this by moving the MsgBtnIcon to be a child of the hover div and add pointer-events: none.
.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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With