가오리의 코딩일기
고스트 본문
https://www.youtube.com/playlist?list=PL-eeIUD86IjSyxTbGT7wY3Hie_HA5bKvg
<!DOCTYPE html>
<html lang="ko">
<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>Ghost</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="ghost">
<div class="body">
<div class="face">
<div class="eye"></div>
<div class="eye"></div>
<div class="mouse"></div>
</div>
</div>
<div class="bottom">
<dib class="leg"></dib>
<dib class="leg"></dib>
<dib class="leg"></dib>
<dib class="leg"></dib>
<dib class="leg"></dib>
</div>
</div>
<script>
document.body.addEventListener("mousemove", function (e) {
document.querySelector(".ghost").style.left = e.pageX + "px";
document.querySelector(".ghost").style.top = e.pageY + "px";
});
</script>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100%;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: black;
}
.ghost {
animation: moveUpDown 3s infinite;
position: absolute;
}
@keyframes moveUpDown {
0% {
margin-top: 0px;
}
50% {
margin-top: -50px;
}
100% {
margin-top: 0px;
}
}
.ghost .body {
width: 120px;
height: 160px;
background-color: white;
border-top-left-radius: 45%;
border-top-right-radius: 45%;
position: relative;
}
.ghost .body .face {
display: flex;
width: 70px;
justify-content: space-between;
flex-wrap: wrap;
position: absolute;
top: 40px;
left: 50%;
transform: translateX(-50%);
}
.ghost .body .eye {
width: 19px;
height: 19px;
border-radius: 50%;
background-color: #333;
}
.ghost .body .mouse {
width: 33px;
height: 15px;
background-color: #333;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
margin-left: 18px;
margin-top: 13px;
}
.ghost .bottom {
display: flex;
}
.ghost .bottom .leg {
background-color: white;
width: 24px;
height: 15px;
border-bottom-left-radius: 30px;
border-bottom-right-radius: 30px;
}
.ghost .bottom .leg:nth-child(2n) {
background-color: black;
position: relative;
top: -6px;
border-radius: 50%;
}
'HTML+CSS+JavaScript > 만들기' 카테고리의 다른 글
University Website Design - Easy Tutorials (0) | 2022.05.24 |
---|---|
PlayList (0) | 2022.05.23 |
HTML5와 CSS3를 사용해서 웹 페이지 하나 만들어보기 (0) | 2022.05.13 |
3D Flip Button 만들기 (0) | 2022.05.11 |
타이핑 효과 랜딩 페이지 만들기 (0) | 2022.05.10 |