유튜브 영상배경 - 반복 애니메이션
고정이미지배경
3D 애니메이션
<!-- YOUTUBE VIDEO -->
<section class="youtube">
<div class="youtube__area">
<div id="player"></div>
</div>
<div class="youtube__cover"></div>
<div class="inner">
<img src="./images/floating1.png" alt="Icon" class="floating floating1" />
<img src="./images/floating2.png" alt="Icon" class="floating floating2" />
<img src="./images/floating3.png" alt="Icon" class="floating floating3" />
</div>
</section>
.youtube .inner {
height: 700px;
}
.youtube .floating1 {
position: absolute;
top: 50px;
left: 0;
}
.youtube .floating2 {
position: absolute;
top: 350px;
left: 150;
}
.youtube .floating3 {
position: absolute;
bottom: -200px;
right: 0;
}
// 범위 랜덤 함수(소수점 2자리까지)
function random(min, max) {
// `.toFixed()`를 통해 반환된 문자 데이터를,
// `parseFloat()`을 통해 소수점을 가지는 숫자 데이터로 변환
return parseFloat((Math.random() * (max - min) + min).toFixed(2))
}
function floatingObject(selector, delay, size) {
// gsap.to(요소, 시간, 옵션);
gsap.to(selector, random(1.5, 2.5), {
y: size,
repeat: -1, //무한반복
yoyo: true,
ease: Power1.easeInOut,
delay: random(0, delay) // 1초뒤에 애니메이션 실행 / 지연시간
});
}
floatingObject('.floating1', 1, 15);
floatingObject('.floating2', .5, 15);
floatingObject('.floating3', 1.5, 20);
<!-- SEASON PRODUCT -->
<section class="season-product">
<div class="inner">
<img src="./images/floating3.png" alt="Icon" class="floating floating3" />
<img src="./images/season_product_image.png" alt="" class="product" />
<div class="text-group">
<img src="./images/season_product_text1.png" alt="" class="title" />
<img src="./images/season_product_text2.png" alt="" class="description" />
<div class="more">
<a href="javascript:void(0)" class="btn">자세히보기</a>
</div>
</div>
</div>
</section>
<!-- RESERVE COFFEE -->
<Section class="reserve-coffee">
<div class="inner">
<img src="./images/reserve_logo.png" alt="" class="reserve-logo"/>
<div class="text-group">
<img src="./images/reserve_text.png" alt="" class="description" />
<div class="more">
<a href="javascript:void(0)" class="btn btn--gold">자세히보기</a>
</div>
</div>
<img src="./images/reserve_image.png" alt="" class="product" />
</div>
</Section>
<!-- PICK YOUR FAVORITE -->
<section class="pick-your-favorite">
<div class="inner">
<div class="text-group">
<img src="./images/favorite_text1.png" alt="" class="title" />
<img src="./images/favorite_text2.png" alt="" class="description" />
<div class="more">
<a href="javascript:void(0)" class="btn btn--white">자세히보기</a>
</div>
</div>
</div>
</section>
/* SEASON PRODUCT */
.season-product {
background-image: url("../images/season_product_bg.jpg");
}
.season-product .inner {
height: 400px;
}
.season-product .floating3 {
position: absolute;
top: -200px;
right: 0;
}
.season-product .text-group {
position: absolute;
top: 110px;
right: 100px;
}
.season-product .text-group .title {
margin-bottom: 10px;
}
.season-product .text-group .description {
margin-bottom: 15px;
}
.season-product .text-group .more {
}
/* RESERVE COFFEE */
.reserve-coffee {
background-image: url("../images/reserve_bg.jpg");
}
.reserve-coffee .inner {
height: 400px;
}
.reserve-coffee .reserve-logo {
position: absolute;
top: 110px;
left: 0;
}
.reserve-coffee .text-group {
position: absolute;
top: 124px;
left: 208px;
}
.reserve-coffee .product {
position: absolute;
top: 0;
right: 0;
}
/* PICK YOUR FAVORITE */
.pick-your-favorite {
background-image: url("../images/favorite_bg.jpg");
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
background-size: cover;
}
.pick-your-favorite .inner {
padding: 110px 0;
}
.pick-your-favorite .text-group {
margin-left: 100px;
width: 362px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
}
.pick-your-favorite .text-group .title {
margin-bottom: 40px;
}
.pick-your-favorite .text-group .description {
margin-bottom: 40px;
}
<!-- RESERVE STORE -->
<section class="reserve-store">
<div class="inner">
<div class="medal">
<div class="front">
<img src="./images/reserve_store_medal_front.png" alt="" />
</div>
<div class="back">
<img src="./images/reserve_store_medal_back.png" alt="" />
<a href="javascript:void(0)" class="btn">매장안내</a>
</div>
</div>
</div>
</section>
/* RESERVER STORE */
.reserve-store {
background-image: url("../images/reserve_store_bg.jpg");
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
background-size: cover;
}
.reserve-store .inner {
height: 600px;
display: flex;
justify-content: center;
align-items: center;
}
.reserve-store .medal {
width: 334px;
height: 334px;
perspective: 600px;
}
.reserve-store .medal .front,
.reserve-store .medal .back {
width: 334px;
height: 334px;
position: absolute;
backface-visibility: hidden;
transition: 1s;
}
.reserve-store .medal .front {
transform: rotateY(0deg);
}
.reserve-store .medal:hover .front {
transform: rotateY(180deg);
}
.reserve-store .medal .back {
transform: rotateY(-180deg);
}
.reserve-store .medal:hover .back {
transform: rotateY(0deg);
}
.reserve-store .medal .back .btn{
position: absolute;
top: 240px;
left: 0;
right: 0;
margin: auto;
}