Button Design (HTML/CSS)

박찬영·2024년 1월 20일
0

Toy Project

목록 보기
9/13
post-thumbnail

1. html 코드

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Button Design</title>
    <link href="./style.css" rel="stylesheet">
</head>
<body>
    <button class="btn btn-swap">
        Buy <span>Sold Out</span>
    </button>
</body>
</html>

2. css 코드

*{
    margin:0;
    padding:0;
    box-sizing: border-box;
}

body{
    background-color: #204063;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn{
    background: none;
    border: 2px solid white;
    font-size: 35px;
    color: white;
    padding: 20px 40px;
    width: 250px;
    cursor: pointer;
    position: relative;
}

.btn-swap span{
    position: absolute;
    top: 0;
    left: 0;
    padding: 20px 40px;
    width: 100%;
    opacity: 0;
    transition: opacity 0.5s;
}

.btn-swap:hover span{
    opacity: 1;
}

.btn-swap::before{
    content:'';
    width: 0%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    background-color: #ed4848;
    transition: width 0.5s;
}

.btn-swap:hover::before{
    width: 100%;
}

3. 결과

profile
블로그 이전했습니다 -> https://young-code.tistory.com

0개의 댓글

관련 채용 정보