<div class="container">
<div class="btn1_container">
<div class="flipBtn">
<div class="btn"></div>
</div>
<span class="circle"></span>
</div>
</div>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.container {
width: 100vw;
height: 100vh;
overflow: hidden;
background: linear-gradient(to right, #e9e4f0, #d3cce3);
display: flex;
justify-content: center;
align-items: center;
}
.btn1_container {
width: 400px;
height: 400px;
background-color: black;
display: flex;
justify-content: center;
align-items: center;
position: relative;
box-shadow: -1px 3px 22px 0px rgba(0, 0, 0, 0.75);
background-image: linear-gradient(315deg, #bf3a30 0%, #864ba2 74%);
}
.flipBtn {
width: 150px;
height: 54px;
background-color: #fff;
border-radius: 50px;
position: relative;
border: 2px solid #111;
position: relative;
z-index: 10;
transform-origin: left;
transition: all 500ms cubic-bezier(0.77, 0, 0.175, 1);
}
.btn {
width: 50px;
height: 50px;
border-radius: 50px;
background-color: #3bb78f;
position: absolute;
left: 0px;
transition: all 300ms 500ms cubic-bezier(1, 0, 1, 0.14);
z-index: 10;
overflow: hidden;
border: 2px solid #fff;
}
.move {
left: 97px;
background-image: linear-gradient(315deg, #3bb78f 0%, #0bab64 74%);
}
.drop {
transform: rotate(90deg);
}
.circle {
width: 0px;
height: 0px;
background-image: linear-gradient(315deg, #3bb78f 0%, #0bab64 74%);
position: absolute;
z-index: 2;
transition: all 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.expand {
width: 100%;
height: 100%;
}
const flipBtn = document.querySelector(".flipBtn");
const btn = document.querySelector(".btn");
const circle = document.querySelector(".circle");
flipBtn.addEventListener("click", () => {
btn.classList.toggle("move");
flipBtn.classList.toggle("drop");
circle.classList.toggle("expand");
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.