JSFiddle - React, Tailwind, and code Playground
by Mykola Dolynskyi
HTML
<div class="parent" style="width: 300px; height: 300px; background-color: white">
<div class="button_wrap">
<div class="slide">Contact us!</div><div id="float-button-contact-us"><div></div></div>
</div>
</div>
CSS
body {
--colorGinFocus:#FFC6C5;
--colorGinAppBackground: #fbf8f8;
}
.button_wrap {
position: fixed;
right: 20px;
bottom: 20px;
border-radius: 50px;
z-index: 999999;
display: flex;
align-items: center;
justify-content: center;
}
.slide {
width: 0px;
height: 0px;
}
#float-button-contact-us>div {
position: relative;
}
#float-button-contact-us>div::before {
content: " ";
width: 37px;
height: 37px;
background-image: url("https://djsite.youpal.ninja/themes/custom/djt/logo.svg");
background-repeat: no-repeat;
background-size: 100%;
position: absolute;
transform: translate(-48%, -40%);
filter: brightness(0) invert(1);
transition: all 0.5s ease-in-out;
}
#float-button-contact-us:hover>div::before {
filter: none;
}
#float-button-contact-us {
position: relative;
right: 20px;
bottom: 20px;
width: 50px;
height: 50px;
border-radius: 50px;
z-index: 999999;
transition: all 0.5s ease-in-out;
background-color: var(--colorGinFocus);
border: 10px solid transparent;
box-shadow: 5px 6px 12px 4px rgba(0, 0, 0, 0.62);
-webkit-box-shadow: 5px 6px 12px 4px rgba(0, 0, 0, 0.62);
-moz-box-shadow: 5px 6px 12px 4px rgba(0, 0, 0, 0.62);
display: flex;
align-items: center;
justify-content: center;
}
#float-button-contact-us::before {
z-index: -1;
}
#float-button-contact-us:hover {
background-color: var(--colorGinAppBackground);
border: 10px solid var(--colorGinFocus);
cursor: pointer;
}
#float-button-contact-us:after {
z-index: -2;
content: "";
position: absolute;
display: block;
border-radius: 50%;
height: 0%;
width: 0%;
margin: auto;
background: var(--colorGinAppBackground);
top: 50%;
left: 50%;
transform: translateY(-50%) translateX(-50%);
transition: all 0.5s ease-in-out;
}
#float-button-contact-us:hover:after {
width: 100%;
height: 100%;
}