์คํ๋ฒ ์ค ๋ฆฌ์์ฆ HTML
<section class="rewards">
<div class="bg-left"></div>
<div class="bg-right"></div>
<div class="inner">
<div class="btn-group">
<div class="btn btn--reverse sign-up">ํ์๊ฐ์
</div>
<div class="btn sign-in">๋ก๊ทธ์ธ</div>
<div class="btn gift">e-Gift ์ ๋ฌผํ๊ธฐ</div>
</div>
</div>
</section>
- ๊ธฐ์กด ์ ๋ ฌ ๋ฐฉ์์ธ bg-left, bg-right, inner ์ฌ์ฉ
- ๋ฒํผ 3๊ฐ์ง ๊ตฌ์ฑ: ํ์๊ฐ์ , ๋ก๊ทธ์ธ, e-Gift ์ ๋ฌผํ๊ธฐ
์คํ๋ฒ ์ค ๋ฆฌ์์ฆ--์์น CSS
.rewards {
position: relative;
}
.rewards .bg-left {
width: 50%;
height: 100%;
background-color: #272727;
position: absolute;
top: 0;
left: 0;
}
.rewards .bg-right {
width: 50%;
height: 100%;
background-color: #d5c798;
position: absolute;
top: 0;
right: 0;
}
.rewards .inner {
background-image: url("../images/rewards.jpg");
height: 241px;
}
- rewards class: ๋ถ๋ชจ์์๋ฅผ ๊ธฐ์ค
- bg-left class: rewards class ๊ธฐ์ค์ผ๋ก ๋ฐฐ์น
- bg-left class: ๊ฐ๋ก 50%, ์ธ๋ก 100%
- bg-left class: ๋ฐฐ๊ฒฝ ์ #272727
- bg-left class: ์๋ก 0, ์ผ์ชฝ์์ 0 ์์น
- bg-right class: rewards class ๊ธฐ์ค์ผ๋ก ๋ฐฐ์น
- bg-right class: ๊ฐ๋ก 50% ์ธ๋ก 100%
- bg-right class: ๋ฐฐ๊ฒฝ ์ #d5c798
- bg-right class: ์๋ก 0, ์ค๋ฅธ์ชฝ์์ 0 ์์น
- inner class: ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง reward.jpg ์ฌ์ฉ
- inner class: ์ธ๋ก 241px
์คํ๋ฒ ์ค ๋ฆฌ์์ฆ--๋ฒํผ CSS
.rewards .btn-group {
position: absolute;
bottom: 24px;
right: 0;
width: 250px;
display: flex;
flex-wrap: wrap;
}
.rewards .btn-group .btn.sign-up {
margin-right: 10px;
}
.rewards .btn-group .btn.sign-in {
width: 110px;
}
.rewards .btn-group .btn.gift {
margin-top: 10px;
flex-grow: 1;
}
- btn-group class: ๋ชจ๋ ๋ฒํผ์ ์ ์ด
- btn-group class: rewards class ๊ธฐ์ค
- btn-group class: ์๋์์ 24px, ์ค๋ฅธ์ชฝ์์ 0 ์์น
- btn-group class: ๊ฐ๋ก 250px
- btn-group class: ์ํ ์ ๋ ฌ
- btn-group class: flex-wrap: wrap → ๋ถ๋ชจ ๋์ด์ ๋ง๊ฒ ์๋ ์ถ์ ํ์ฅ
- btn sign-up class: ์ค๋ฅธ์ชฝ ์ธ๋ถ์ฌ๋ฐฑ 10px
- btn sign-in class: ๊ฐ๋ก 110px (๊ธฐ์กด ์ค์ ์ ๊ฐ์ง์ง ์์)
- btn gift class: ์ ์ธ๋ถ์ฌ๋ฐฑ 10px
- btn gift class: ํ์๊ฐ์ , ๋ก๊ทธ์ธ ๋ฒํผ์ ๊ฐ๋ก ๊ธธ์ด๋งํผ ๋ฒํผ ๊ธธ์ด ์ง์
์คํ๋ฒ ์ค ์ ํ๋ธ ์์ ๋ฐฐ๊ฒฝ HTML
<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>
- ์์ ์์ ์ฌ์ง์ ๋์ด๋ค. (์ ๋๋ฉ์ด์ ํจ๊ณผ๋ฅผ ์์ฑํ๊ธฐ ์ํด์)
์คํ๋ฒ ์ค ์ ํ๋ธ ์์ ๋ฐฐ๊ฒฝ CSS
.youtube {
position: relative;
height: 700px;
background-color: #333;
overflow: hidden;
}
.youtube .youtube__area {
width: 1920px;
position: absolute;
left: 50%;
margin-left: calc(1920px / -2);
top: 50%;
margin-top: calc(1920px * 9 / 16 / -2);
}
.youtube .youtube__area::before {
content: "";
display: block;
width: 100%;
height: 0;
padding-top: 56.25%;
}
.youtube .youtube__cover {
background-image: url("../images/video_cover_pattern.png");
background-color: rgba(0,0,0,.3);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#player {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.youtube .inner {
height: 700px;
}
- youtube class: ์๊ธฐ ์์ ๊ธฐ์ค
- youtube class: ์ธ๋ก 700px
- youtube class: ๋ฐฐ๊ฒฝ ์ #333
- youtube class: ๋์น๋ ์์ ๊ฐ๋ฆผ
- youtube__area class: ๊ฐ๋ก 1920px
- youtube__area class: youtube class ๊ธฐ์ค
- youtube__area class: ์ผ์ชฝ์ผ๋ก๋ถํฐ 50%, ์ผ์ชฝ ์ธ๋ถ์ฌ๋ฐฑ calcํจ์ ๊ณ์ฐํ์ฌ ๊ฐ์ด๋ฐ ๊ธฐ์ค ์ ๋ ฌ
- youtube__area class: ์๋ก๋ถํฐ 50%, ์์ชฝ ์ธ๋ถ์ฌ๋ฐฑ calcํจ์ ๊ณ์ฐํ์ฌ ๊ฐ์ด๋ฐ ๊ธฐ์ค ์ ๋ ฌ
- youtube__area::before class: ์ฝํ ์ธ ๊ณต๋ฐฑ
- youtube__area::before class: ๋ธ๋ญ์์๋ก ์ค์
- ๊ฐ๋ก 100%, ์ธ๋ก 0, padding-top:56.25%๋ก ์์ 16:9 ๋น์จ ์ ์ง
- youtube__cover class: ์ ํ๋ธ์์ ์ด๋ฏธ์ง ๋ฐฐ๊ฒฝ ์ค์
- youtube__cover class: ํฌ๋ช ๋ 30%๋ก ์ค์
- youtube__cover class: youtube class ๊ธฐ์ค
- youtube__cover class: ์์์๋ถํฐ 0, ์ผ์ชฝ์ผ๋ก๋ถํฐ 0 ์์น ์ง์
- youtube__cover class: ๊ฐ๋ก 100%, ์ธ๋ก 100%
- player id: ๊ฐ๋ก 100%, ์ธ๋ก 100%
- player id: youtube class ๊ธฐ์ค
- player id: ์๋ก๋ถํฐ 0, ์ผ์ชฝ์ผ๋ก๋ถํฐ 0 ์์น ์ง์
- inner class: ์ธ๋ก 700px
์คํ๋ฒ ์ค ์ ํ๋ธ ์์ ๋ฐฐ๊ฒฝ--์ด๋ฏธ์ง CSS
.youtube .floating1 {
position: absolute;
top: 50px;
left: 0;
}
.youtube .floating2 {
position: absolute;
top: 350px;
left: 150px;
}
.youtube .floating3 {
position: absolute;
bottom: -200px;
right: 0;
}
- floating1 class: youtube class ๊ธฐ์ค
- floating1 class: ์๋ก๋ถํฐ 50px ์ผ์ชฝ์ผ๋ก๋ถํฐ 0 ์์น ์ง์
- floating2 class: youtube class ๊ธฐ์ค
- floating2 class: ์๋ก๋ถํฐ 350px, ์ผ์ชฝ์ผ๋ก๋ถํฐ 150px ์์น ์ง์
- floating3 class: youtube class ๊ธฐ์ค
- floating3 class: ์๋์์๋ถํฐ -200px, ์ค๋ฅธ์ชฝ๋ถํฐ 0 ์์น ์ง์
์คํ๋ฒ ์ค ์ ํ๋ธ ์์ ๋ฐฐ๊ฒฝ JS
- youtube iframe api ๊ฒ์
- ์๋ ์ฌ์ดํธ๋ก ์ด๋ํ์ฌ ๊ธฐ์กด ์ฝ๋ ๋ณต์ฌ
- bHQqvYy5KYo์ ๊ฐ์ video id ๋ณต์ฌํ์ฌ ํด๋น ์์น์ ๋ถ์ฌ๋ฃ๊ธฐ
- ์๋ ์ฝ๋์ ๊ฐ์ ๋ถ๋ถ๋ง ์ฝ๋ ์์
- videoid๋ฅผ ์ฐ๋ ์ด์ ๋ ์์์ ๊ดํ ์์ ์ ํ๊ธฐ ์ํจ์ด๋ค.
iframe ์ฝ์ ์ ๋ํ YouTube Player API ์ฐธ์กฐ ๋ฌธ์ | YouTube IFrame Player API | Google Developers
Embed a YouTube player in your application.
developers.google.com
function onYouTubeIframeAPIReady() {
new YT.Player('player', {
// <div id="player"></div>
videoId: '8kx8Qxsaeb8', // ์ต์ด ์ฌ์ํ ์ ํ๋ธ ์์ ID
playerVars: {
autoplay: true, // ์๋ ์ฌ์ ์ ๋ฌด
loop: true, // ๋ฐ๋ณต ์ฌ์ ์ ๋ฌด
playlist: '8kx8Qxsaeb8' // ๋ฐ๋ณต ์ฌ์ํ ์ ํ๋ธ ์์ ID ๋ชฉ๋ก
},
events: {
onReady: function (event) {
event.target.mute() // ์์๊ฑฐ
}
}
});
}
- videoId ๋ณ๊ฒฝ
- autoplay๋ฅผ ํตํด ์๋ ์ฌ์
- loop๋ฅผ ํตํด ๋ฐ๋ณต ์ฌ์
- playlist์ ์๋ ์ ํ๋ธ ์์ ์ฌ์
- event target์ mute๋ก ํ์ฌ ์์๊ฑฐ ์ค์
์คํ๋ฒ ์ค ์ ํ๋ธ ์์ ๋ฐฐ๊ฒฝ--์ด๋ฏธ์ง JS
// ๋ฒ์ ๋๋ค ํจ์(์์์ 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)
}
);
}
floatingObject('.floating1', 1, 15);
floatingObject('.floating2', .5, 15);
floatingObject('.floating3', 1.5, 20);
- 1.5์ด๋ถํฐ 2.5์ด๊น์ง ์ ๋๋ฉ์ด์ ๋๋ ์ด๋ฅผ ๋๋ค์ผ๋ก ์ง์
- size๋ฅผ ์ด์ฉํด ์ฌ์ง ์ฌ์ด์ฆ ์ง์
- repeat:-1์ ์ด์ฉํด ๋ฌดํ๋ฐ๋ณต
- yoyo๋ repeat์ด ๋ฐ๋์ ํ์ํ ์์ฑ
- yoyo๋ ๋ด๋ ค๊ฐ ๊ฒฝ๋ก์ ๋๊ฐ์ด ์๋ก ์ฌ๋ผ์จ๋ค.
- ์๋ ์ฌ์ดํธ๋ฅผ ์ด์ฉํด ๊ทธ๋ํ ์์ง์ ์ง์
- https://greensock.com/docs/v2/Easing
Docs
Documentation for GreenSock Animation Platform (GSAP)
greensock.com
- ๋๋ ์ด๋ 0๋ถํฐ 1.5์ด๋ถํฐ 2.5์ด๊น์ง์ค ๋๋ค ์ง์
- floating1์ ๋๋ ์ด 1์ด, ์ฌ์ด์ฆ 15
- floating2๋ ๋๋ ์ด 0.5์ด, ์ฌ์ด์ฆ 15
- floating3์ ๋๋ ์ด 1.5์ด, ์ฌ์ด์ฆ 20
์คํ๋ฒ ์ค ์ ํ๋ธ ์์ ๋ฐฐ๊ฒฝ ์์ฑ๋ณธ

'๐ป Web Develop > โ๏ธ STARBUCKS ๊ฐ๋ฐ์ผ์ง' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
9. ์คํ๋ฒ ์ค 3D ์ ๋๋ฉ์ด์ (0) | 2022.02.07 |
---|---|
8. ์คํ๋ฒ ์ค ๊ณ ์ ์ด๋ฏธ์ง ๋ณ๊ฒฝ (0) | 2022.02.07 |
6. ์คํ๋ฒ ์ค ์์ ์ฌ๋ผ์ด๋ (0) | 2022.02.05 |
5. ์คํ๋ฒ ์ค ์์ฐจ์ ์ ๋๋ฉ์ด์ (0) | 2022.02.04 |
4. ์คํ๋ฒ ์ค ์ ์ญ๋ฐฐ์ง(GSAP) (0) | 2022.02.04 |