코드랩 레퍼런스
Parallax - Dot Menu Style - opacity 본문
See the Pen Parallax = Dot Menu Style - opacity by Webstoryboy (@webstoryboy) on CodePen.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
@import url('https://fonts.googleapis.com/css?family=Playball');
/* font-family: 'Playball', cursive; */
/* reset */
*{margin:0; padding:0}
li,ul {list-style:none}
a {text-decoration:none}
/* dot */
#dot {
position: fixed; right:20px; top: 50%;
transform: translatey(-50%);
}
#dot li {
position:relative; width: 16px; height: 16px;
margin: 8px;
}
#dot li a {
position: absolute; top: 0; left: 0;
width: 100%; height: 100%; outline: none;
border-radius: 50%;
background-color: #fff;
background-color: rgba(255, 255, 255, 0.3);
text-indent: -999em;
cursor: pointer;
border: 2px solid #fff;
transition: border-color 0.3s ease;
}
#dot li a:after {
content: ''; position: absolute; top: 0; left: 0;
width: 100%; height: 100%;
visibility: hidden; opacity: 0;
background: #fff;
border-radius: 50%;
box-shadow: 0 0 1px #fff;
transform: scale(3);
transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s 0.3s;
}
#dot li.active a {
border-color: #fff;
}
#dot li.active a:after {
visibility: visible;
opacity: 1;
transform: scale(1);
transition: opacity 0.3s ease, transform 0.3s ease;
}
/* contents */
#contents {
font-size: 60px;
color:#fff;
text-align: center;
font-family: 'Playball', cursive;
}
#contents > div {
height: 100vh; line-height: 100vh;
}
/* section */
#section1 {background-image: linear-gradient(to top, #c471f5 0%, #fa71cd 100%);}
#section2 {background-image: linear-gradient(to top, #a18cd1 0%, #fbc2eb 100%);}
#section3 {background-image: linear-gradient(120deg, #f6d365 0%, #fda085 100%);}
#section4 {background-image: linear-gradient(120deg, #d4fc79 0%, #96e6a1 100%);}
#section5 {background-image: linear-gradient(120deg, #a6c0fe 0%, #f68084 100%);}
#section6 {background-image: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%);}
</style>
</head>
<body>
<nav id="dot">
<ul>
<li class="active"><a href="#"><em>Intro</em></a></li>
<li><a href="#"><em>Skill</em></a></li>
<li><a href="#"><em>Website</em></a></li>
<li><a href="#"><em>Work</em></a></li>
<li><a href="#"><em>About</em></a></li>
<li><a href="#"><em>Contact</em></a></li>
</ul>
</nav>
<section id="contents">
<div id="section1">
<div class="container">
<div class="sec1">
<h2>Raise Your Head</h2>
</div>
</div>
</div>
<div id="section2">
<div class="container">
<div class="sec2">
<h2>Think Different</h2>
</div>
</div>
</div>
<div id="section3">
<div class="container">
<div class="sec3">
<h2>The Life is only once</h2>
</div>
</div>
</div>
<div id="section4">
<div class="container">
<div class="sec4">
<h2>I must do what I want to do</h2>
</div>
</div>
</div>
<div id="section5">
<div class="container">
<div class="sec5">
<h2>Time is Life itself</h2>
</div>
</div>
</div>
<div id="section6">
<div class="container">
<div class="sec6">
<h2>There is no destiny</h2>
</div>
</div>
</div>
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script>
var dot = $("#dot ul li");
var contents = $("#contents > div");
dot.click(function(e){
e.preventDefault();
var target = $(this);
var index = target.index();
var section = contents.eq(index);
var offset = section.offset().top;
$("html,body").animate({scrollTop:offset},600,"easeInOutExpo");
});
$(window).scroll(function(){
var wScroll = $(this).scrollTop();
if(wScroll >= contents.eq(0).offset().top){
dot.removeClass("active");
dot.eq(0).addClass("active");
}
if(wScroll >= contents.eq(1).offset().top){
dot.removeClass("active");
dot.eq(1).addClass("active");
}
if(wScroll >= contents.eq(2).offset().top){
dot.removeClass("active");
dot.eq(2).addClass("active");
}
if(wScroll >= contents.eq(3).offset().top){
dot.removeClass("active");
dot.eq(3).addClass("active");
}
if(wScroll >= contents.eq(4).offset().top){
dot.removeClass("active");
dot.eq(4).addClass("active");
}
if(wScroll >= contents.eq(5).offset().top){
dot.removeClass("active");
dot.eq(5).addClass("active");
}
});
</script>
</body>
</html>