이 섹션은 2가지 구역으로 구성 되어 있다.
<!--Swiper-->
<link rel="stylesheet" href="https://unpkg.com/swiper@6.8.4/swiper-bundle.min.css" />
<script src="https://unpkg.com/swiper@6.8.4/swiper-bundle.min.js"></script>
<!--NOTICE-->
<section class="notice">
<!--NOTICE LINE-->
<div class="notice-line">
<div class="bg-left"></div>
<div class="bg-right"></div>
<div class="inner">
<div class="inner__left">
<div class="inner__right">
.notice .notice-line {}
.notice .notice-line .bg-left {}
.notice .notice-line .bg-right {}
.notice .notice-line .inner {}
.notice .notice-line .inner__left {}
.notice .notice-line .inner__right {}
<div class="inner__left">
<h2>공지사항</h2>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<a href="javascript:void(0)">크리스마스 & 연말연시 스타벅스 매장 영업시간 변경 안내</a>
</div>
<div class="swiper-slide">
<a href="javascript:void(0)">[당첨자 발표] 2021 스타벅스 플래너 영수증 이벤트</a>
</div>
<div class="swiper-slide">
<a href="javascript:void(0)">스타벅스커피 코리아 애플리케이션 버전 업데이트 안내</a>
</div>
<div class="swiper-slide">
<a href="javascript:void(0)">[당첨자 발표] 뉴이어 전자영수증 이벤트</a>
</div>
</div>
</div>
<a href="javascript:void(0)" class="notice-line__more">
<span class="material-icons">add_circle</span>
</a>
</div>
CSS
.notice .notice-line .inner__left h2 {}
.notice .notice-line .inner__left .swiper-container {}
.notice .notice-line .inner__left .swiper-slide {}
.notice .notice-line .inner__left .swiper-slide a {}
.notice .notice-line .inner__left .notice-line__more {}
.notice .notice-line .inner__left .notice-line__more .material-icons {}
JS
swiper-container의 기능을 명시해줘야 정상적으로 작동한다
new Swiper('.notice-line .swiper-container',{
direction: 'vertical',
autoplay: true,
loop: true
});
<div class="inner__right">
<h2>스타벅스 프로모션</h2>
<div class="toggle-promotion">
<div class="material-icons">upload</div>
</div>
</div>
.notice .notice-line .inner__right h2 {}
.notice .notice-line .inner__right .toggle-promotion {}
.notice .notice-line .inner__right .toggle-promotion .material-icons {}
<!-- PROMOTION -->
<div class="promotion">
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<img src="./images/promotion_slide1.jpg" alt="2021 뉴이어, 스타벅스와 함께 즐겁고 활기차게 시작하세요!">
<a href="javascript:void(0)" class="btn">자세히 보기</a>
</div>
<div class="swiper-slide">
<img src="./images/promotion_slide2.jpg" alt="2021 뉴이어, 스타벅스와 함께 즐겁고 활기차게 시작하세요!">
<a href="javascript:void(0)" class="btn">자세히 보기</a>
</div>
<div class="swiper-slide">
<img src="./images/promotion_slide3.jpg" alt="2021 뉴이어, 스타벅스와 함께 즐겁고 활기차게 시작하세요!">
<a href="javascript:void(0)" class="btn">자세히 보기</a>
</div>
<div class="swiper-slide">
<img src="./images/promotion_slide4.jpg" alt="2021 뉴이어, 스타벅스와 함께 즐겁고 활기차게 시작하세요!">
<a href="javascript:void(0)" class="btn">자세히 보기</a>
</div>
<div class="swiper-slide">
<img src="./images/promotion_slide5.jpg" alt="2021 뉴이어, 스타벅스와 함께 즐겁고 활기차게 시작하세요!">
<a href="javascript:void(0)" class="btn">자세히 보기</a>
</div>
</div>
</div>
<div class="swiper-pagination"></div>
<div class="swiper-prev">
<div class="material-icons">arrow_back</div>
</div>
<div class="swiper-next">
<div class="material-icons">arrow_forward</div>
</div>
</div>
CSS
.notice .promotion {}
height: 693px;
background-color: #f6f5ef;
position: relative;
transition: height .4s; 자연스럽게 숨길수 있게 한다
overflow: hidden; hide 될 때 넘치는 부분을 다 숨긴다
.notice .promotion.hide {}
.notice .promotion .swiper-container {}
.notice .promotion .swiper-slide {}
.notice .promotion .swiper-slide-active {} 현재 활성화된 슬라이드.
.notice .promotion .swiper-slide .btn {}
.notice .promotion .swiper-pagination {}
bottom: 40px; swiper-slide 밑 40px 아래에 위치시키기
left: 0;
right: 0;
.notice .promotion .swiper-pagination .swiper-pagination-bullet {}
.notice .promotion .swiper-pagination .swiper-pagination-bullet-active {} 현재 선택된 슬라이드의 위치인 불렛을 다른이미지로 표시해주기
.notice .promotion .swiper-pagination .swiper-pagination-bullet:last-chld {}
.notice .promotion .swiper-prev,
.notice .promotion .swiper-next {}
이전 버튼, 다음버튼 둘다 적용
.notice .promotion .swiper-prev {}
.notice .promotion .swiper-next {}
.notice .promotion .swiper-prev:hover,
.notice .promotion .swiper-next:hover {}
JS
new Swiper('.promotion .swiper-container',{
slidesPerView: 3,
spaceBetween: 10,
centeredSlides: true,
loop: true,
autoplay: {
delay: 3000,
},
pagination: {
el: '.promotion .swiper-pagination',
clickable: true
},
navigation: {
prevEl: '.promotion .swiper-prev',
nextEl: '.promotion .swiper-next'
}
});
const promotionEl = document.querySelector('.promotion');
const promotionToggleBtn = document.querySelector('.toggle-promotion');
let isHidePromotion = false;
promotionToggleBtn.addEventListener('click', function(){
isHidePromotion = !isHidePromotion;
if (isHidePromotion) { // true -> 숨기기
promotionEl.classList.add('hide');
} else { // false -> 보이기
promotionEl.classList.remove('hide');
}
});
1. 어두운 왼쪽 배경
2. 금색 오른쪽 배경
a. btn-group(회원가입, 로그인, 선물하기)
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>
CSS
.rewards {}
.rewards .bg-left {}
.rewards .bg-right {}
.rewards .inner {}
.rewards .btn-group {}
.rewards .btn-group .btn.sign-up {}
.rewards .btn-group .btn.sign-in {}
.rewards .btn-group .btn.gift {}
<div class="container">
<div class="item"></div>
</div>
.container {
width: 100px;
background-color: orange;
}
.container .item {
width: 100%;
padding-top: 50%;
}
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"/>
</div>
</section>
CSS
.youtube {}
.youtube .youtube__area {}
영상 재생 영역 원래 #player로 조절해야 하는데 잘 안돼서 이걸루 함
.youtube .youtube__area ::before {}
.youtube .youtube__cover {}
/ #player {} / 이 설정을 적용하면 비디오가 사라져서 코멘트처리함
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
.youtube .inner {}
둥둥 스티커는 이너영역 안에 붙일 것
height:700px;
.youtube .floating1 {}
position: absolute;
top: 50px;
left: 0;
.youtube .floating2 {}
position: absolute;
top: 350px;
left: 150;
.youtube .floating3 {} 은 그 다음 섹션 사이 중간에 배치할 것인데 유튜브 overflow:hidden으로 만들어서 짤리게됨. -> 그 다음 섹션으로 넣어서 배치하자
JS
// 2. This code loads the IFrame Player API code asynchronously.
let tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
let firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
function onYouTubeIframeAPIReady() {
new YT.Player('player', {
videoId: 'An6LvWQuj_8', // 최초 재생할 유튜브 영상 id
playerVars: {
autoplay: true,
loop: true,
playlist: 'An6LvWQuj_8'
},
events: {
onReady: function(event){
event.target.mute(); // 음소거
}
}
});
}
// 범위 랜덤 함수(소수점 2자리까지)
function random(min, max) {
// `.toFixed()`를 통해 반환된 문자 데이터를,
// `parseFloat()`을 통해 소수점을 가지는 숫자 데이터로 변환
return parseFloat((Math.random() * (max - min) + min).toFixed(2))
}
function floatingObject(selector, delay, size) {
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);
<section class="pick-your-favorite scroll-spy">
<div class="inner">
<div class="text-group">
<img src="./images/favorite_text1.png" alt="" class="title back-to-position to-right delay-0"/>
<img src="./images/favorite_text2.png" alt="" class="description back-to-position to-right delay-1"/>
<div class="more back-to-position to-right delay-2">
<a href="javascript:void(0)" class="btn btn--white">자세히 보기</a>
</div>
</div>
</div>
</section>
.pick-your-favorite {}
.pick-your-favorite .inner {}
.pick-your-favorite .text-group {}
.pick-your-favorite .text-group .title {}
.pick-your-favorite .text-group .description {}
<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>
CSS
.reserve-store .inner{}
.reserve-store .medal {}
.reserve-store .medal .front,
.reserve-store .medal .back {}
.reserve-store .medal .front {}
.reserve-store .medal:hover .front {}
.reserve-store .medal .back {}
.reserve-store .medal:hover .back {}
<!-- ScrollMagic -->
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.8/ScrollMagic.min.js" integrity="sha512-8E3KZoPoZCD+1dgfqhPbejQBnQfBXe8FuwL4z/c8sTrgeDMFEnoyTlH3obB4/fV+6Sg0a0XF+L/6xS4Xx1fUEg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
JS
화면에 0.8 부분에 오면 show 클래스를 넣었다 빼준다
const spyEls = document.querySelectorAll('section.scroll-spy');
spyEls.forEach(function (spyEl) {
new ScrollMagic
.Scene({
triggerElement: spyEl,
triggerHook: .8,
})
.setClassToggle(spyEl, 'show')
.addTo(new ScrollMagic.Controller());
});
css
부하가 많이 걸리는 효과 처리는 자바스크립트보다 css로 처리해주는 것이 좋다
.back-to-position {}
.back-to-position.to-right {} 일치선택자(동시에 만족 &)
.back-to-position.to-left {} 일치선택자
.show .back-to-position {}
.show .back-to-position.delay-0 {}
.show .back-to-position.delay-1 {}
.show .back-to-position.delay-2 {}
<footer>
<div class="inner">
<ul class="menu">
<li><a href="javascript:void(0)" class="green">개인정보처리 방침</a></li>
<li><a href="javascript:void(0)">영상정보처리기기 운영관리 방침</a></li>
<li><a href="javascript:void(0)">홈페이지 이용약관</a></li>
<li><a href="javascript:void(0)">위치정보 이용약관</a></li>
<li><a href="javascript:void(0)">스타벅스 카드 이용약관</a></li>
<li><a href="javascript:void(0)">윤리경영 핫라인</a></li>
</ul>
<div class="btn-group">
<a href="javascript:void(0)" class="btn btn--white">찾아오시는 길</a>
<a href="javascript:void(0)" class="btn btn--white">신규 입점 제의</a>
<a href="javascript:void(0)" class="btn btn--white">사이트 맵</a>
</div>
<div class="info">
<span>사업자등록번호 201-81-21515</span>
<span>(주)스타벅스 코리아 대표이사 이석구</span>
<span>TEL : 02) 3015-1100 / FAX : 02) 3015-1106</span>
<span>개인정보 책임자: 강기원</span>
</div>
<p class="copyright">
© <span class="this-year"></span> Starbucks Coffee Company. All Rights Reserved.
<!-- html 특수기호 html entities -->
</p>
<img src="./images/starbucks_logo_only_text.png" alt="" class="logo">
</div>
</footer>
const thisYear = document.querySelector('.this-year');
thisYear.textContent = new Date().getFullYear();
CSS
footer .menu li {}
footer .menu li::before {}
footer .menu li:last-child::before {}
footer .menu li a {}
footer .menu li a.green {}
footer .logo {}
<!-- ScrollToPlugIn -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/ScrollToPlugin.min.js" integrity="sha512-tQFq+nb/TSS648SDzWbSj0A67t4I1PFzR0U6Oi/yEYFyUbAIwg74SOCbr7t2X1Rn+iln7sYwfh8y+z7p0gddOw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<div id="to-top">
<div class="material-icons">arrow_upward</div>
</div>
JS
버튼을 누르면 맨 위로 스크롤 되는 기능 넣기
const badgeEl= document.querySelector('header .badges');
const toTopEl = document.querySelector('#to-top');
window.addEventListener('scroll',_.throttle(function(){
if (window.scrollY > 500) { //스크롤이 아래쪽에 있을 때
// 배지 숨기기
gsap.to(badgeEl, .6, {
opacity: 0,
display: 'none'
});
// 버튼 보이기
gsap.to(toTopEl, .2, {
x: 0
})
} else { // 스크롤이 메인부분에 있을 때
// 배지 보이기
gsap.to(badgeEl, .6, {
opacity: 1,
display: 'block'
});
// 오른쪽으로 버튼 숨기기
gsap.to(toTopEl, .2, {
x: 100
})
}
},300));
toTopEl.addEventListener('click', function(){
gsap.to(window, .7, {
scrollTo: 0
})
})