css 배경 효과

리린·2021년 9월 18일
0

css

목록 보기
2/13

강의

https://youtu.be/5RoXCs54CN8

스크린샷

필요한 코드

  1. 배경화면
background: linear-gradient(to left, #8942a8, #ba382f);
  • 그라데이션 효과를 준다
  1. 공통 박스 만들기
display: block;
list-style: none;
width: 25px;
height: 25px;
background: rgba(255, 255, 255, 0.2);
        animation: animate 20s linear infinite;
  • 블록을 디자인하고, 애니메이션 효과를 준다
  1. 각 박스마다 스타일 다르게 주기
width: 30px;
height: 30px;
혹은 
width: 100px;
height: 100px;
  1. 각 li에 애니메이션 딜레이 효과와 속도를 준다
animation-delay: 0s;
혹은 
animation-delay: 1.5s;
animation-duration: 10s;
혹은 
animation-delay: 5.5s;
혹은 
animation-delay: 0s;
animation-duration: 15s;
혹은 
animation-delay: 0s;
혹은 
animation-delay: 3.5s;
 
  1. 각 li에 left:퍼센트 로 위치를 조정한다
left: 12%
혹은
left: 75%
혹은 
left: 61%;
  1. 박스 굴리는 에니메이션 추가
@keyframes animate {
        0% {
          transform: translateY(0) rotate(0deg);
          opacity: 1;
        }
        100% {
          transform: translateY(-800px) rotate(360deg);
          opacity: 0;
        }
      }
  1. html코드
<div class="animation-area">
      <ul class="box-area">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
      </ul>
    </div>

전체 코드

<!DOCTYPE html>
<!--Code by Divinector - divinectorweb.com-->
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>animated background with pure css and html</title>
	<link href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@700&display=swap" rel="stylesheet">
	<style>
    * {
	margin: 0;
	padding: 0;
}
body {
	font-family: 'Baloo 2', cursive;
}
.banner-text {
	width: 100%;
	position: absolute;
	z-index: 1;
}
.banner-text ul {
	height: 50px;
	float: right;
}
.banner-text ul li {
	display: inline-block;
	padding: 40px 15px;
	text-transform: uppercase;
	color: #fff;
	font-size: 20px;
}
.banner-text ul li:hover {
	cursor: pointer;
}
.banner-text h2 {
	text-align: center;
	color: #fff;
	font-size: 50px;
	margin-top: 20%;
}
.animation-area {
	background: linear-gradient(to left, #8942a8, #ba382f);
	width: 100%;
	height: 100vh;
}
.box-area {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}
.box-area li {
	position: absolute;
	display: block;
	list-style: none;
	width: 25px;
	height: 25px;
	background: rgba(255, 255, 255, 0.2);
	animation: animate 20s linear infinite;
	bottom: -150px;
}
.box-area li:nth-child(1) {
	left: 86%;
	width: 80px;
	height: 80px;
	animation-delay: 0s;
}
.box-area li:nth-child(2) {
	left: 12%;
	width: 30px;
	height: 30px;
	animation-delay: 1.5s;
	animation-duration: 10s;
}
.box-area li:nth-child(3) {
	left: 70%;
	width: 100px;
	height: 100px;
	animation-delay: 5.5s;
}
.box-area li:nth-child(4) {
	left: 42%;
	width: 150px;
	height: 150px;
	animation-delay: 0s;
	animation-duration: 15s;
}
.box-area li:nth-child(5) {
	left: 65%;
	width: 40px;
	height: 40px;
	animation-delay: 0s;
}
.box-area li:nth-child(6) {
	left: 15%;
	width: 110px;
	height: 110px;
	animation-delay: 3.5s;
}
@keyframes animate {
	0% {
		transform: translateY(0) rotate(0deg);
		opacity: 1;
	}
	100% {
		transform: translateY(-800px) rotate(360deg);
		opacity: 0;
	}
}

    </style>

</head>
<body>
	<div class="banner-text">
		<ul>
			<li>Home</li>
			<li>About</li>
			<li>Portfolio</li>
			<li>Services</li>
			<li>Contact</li>
		</ul>
		<h2>Welcome to our Website</h2>
	</div>
	<div class="animation-area">
		<ul class="box-area">
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
		</ul>
	</div>
</body>
</html>
profile
개발자지망생

0개의 댓글