Build Slice button animation on hover with CSS-only project | Advance CSS project

slice button hover animation with css only
slice button hover animation with CSS only

Hi, welcome here in this tutorial we are going to develop a Slice button animation on hover with CSS only a project so let’s start it.

Here is your index.html file, copy the code below and paste it into index.html.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Slice button</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <a href="#">Slice Button</a>
</body>
</html>
HTML

Here is your code for the App.css file:

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}

body{
    height: 100vh;
    display:grid;
    place-items:center;
    background-image: linear-gradient(135deg,  #43a1f8 10%, #671dc7 100%);
}

.btn{
    position: relative;
    width: 250px;
    height: 80px;
    display: grid;
    place-items: center;
    background-image: linear-gradient(135deg, rgb(117, 29, 189) 10%, rgb(30, 138, 210) 100%);
    color: white;
    border-radius: 80px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-decoration: none;
    border-top: 2px solid #e6e6fa;
    border-left: 2px solid #e6e6fa;
    padding-left: 60px;
    overflow: hidden;
    transition: 0.5s ease-in-out;
}

.btn:hover{
    padding-left: 0px;
    padding-right: 60px;
    color: white;
}

.btn span {
    position: absolute;
    display: grid;
    place-items: center;
    left: 5px;
    width: 70px;
    height: 70px;
    background-image: linear-gradient(135deg, rgb(200, 200, 200), rgb(250, 250, 250));
    color: #000;
    border-radius: 50%;
    font-size: 2rem;
    font-weight: bolder;
    transition: 0.5s cubic-bezier(0.4, 0, 1, 1);
}
.btn:hover span{
    left: calc(100% - 76px);
}

.btn:after{
    position: absolute;
    content: "";
    width: 80px;
    height: 100%;
    z-index: 1;
    background: rgb(255, 255, 255, 0.4);
    transform: translateX(-175px) skew(25deg);
    transition: 0.75s ease-in-out;
}

.btn:hover::after {
    transform: translateX(175px) skew(25deg);
}
CSS

After writing the code into the files (don’t forget to save it ?,) and then open your HTML file in the browser.


Here is a complete tutorial on building a button animation on hover effect app in CSS only.