코드랩 레퍼런스

Parallax - Dot Menu - Scale 본문

SAMPLE

Parallax - Dot Menu - Scale

webstoryboy 2018. 2. 7. 20:09

See the Pen Parallax = Dot Menu Style1 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;
		   display: block;
			width: 16px; height: 16px; 
			border-radius:50%; 
			margin:8px; 
			box-shadow: 0 0 0 2px rgba(255, 255, 255, 0); 
			transition: box-shadow 0.3s ease;
		}
		#dot li a {
			background-color: rgba(255, 255, 255, 0.7);
			transition: background-color 0.3s ease, transform 0.3s ease;
			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;
			position: absolute;
		}
		#dot li.active {
			box-shadow: 0 0 0 2px white;
		}
		#dot li.active a {
			transform: scale(0.4);
		}
		#dot li a em {
			opacity:0; 
			position: absolute; right: 37px; top:-7px; 
			background: rgba(0,0,0,0.55); 
			color:#fff; 
			padding: 8px 14px 5px 14px; 
			display:block; 
			transition: all 0.3s ease; opacity:0;
		}

		/* 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, #a18cd1 0%, #fbc2eb 100%);}
		#section2 {background-image: linear-gradient(to top, #c471f5 0%, #fa71cd 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>Think Different</h2>
				</div>
			</div>
		</div>
		<div id="section2">
			<div class="container">
				<div class="sec2">
					<h2>Raise Your Head</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>

Share

Ad

Comments