HMTL & CSS

Button Animation Html / Css 코드

동띠기 2020. 3. 24. 18:01
728x90

출처 : 유튜브 DarkCode - Button With Awesome Hover Effects Using HTML & CSS

https://www.youtube.com/watch?v=SP0wAmjbaQ4

 

Hover시 움직이는 효과를 가진 버튼입니다.

 

 

html

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="day3_button_Animation.css">
    <title>Day3</title>
</head>
<body>
    <button class="btn">
        Hover Me
    </button>
</body>
</html>

 

css

@charset "utf-8";

*{
    margin: 0;
    padding: 0;
}
body{
    background: #353b48;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn{
    width: 200px;
    height: 60px;
    background: none;
    border: 4px solid;
    color: #3498db;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    font-size: 16px;
    position: relative;
}
.btn::before, .btn::after{
    content: "";
    position: absolute;
    width: 14px;
    height: 4px;
    background: #353b48;
    transform: skewX(50deg);
    transition: .4s linear;
}
.btn::before{
    top: -4px;
    left: 10%;
}
.btn::after{
    bottom: -4px;
    right: 10%;
}

.btn:hover::before{
    left: 80%;
}
.btn:hover::after{
    right: 80%;
}

 

728x90