cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <link href="https://fonts.googleapis.com/css?family=Cairo" rel="stylesheet">

<nav id="nav">
	<ul>
		<li class="active"><a href="#section1"><span>Intro</span></a></li>
		<li><a href="#section2"><span>Skill</span></a></li>
		<li><a href="#section3"><span>Coding</span></a></li>
		<li><a href="#section4"><span>Design</span></a></li>
		<li><a href="#section5"><span>About</span></a></li>
		<li><a href="#section6"><span>Contact</span></a></li>
	</ul>
</nav>

<div id="dot">
	<ul>
		<li class="active"><a href="#section1"><span>Intro</span></a></li>
		<li><a href="#section2"><span>Skill</span></a></li>
		<li><a href="#section3"><span>Coding</span></a></li>
		<li><a href="#section4"><span>Design</span></a></li>
		<li><a href="#section5"><span>About</span></a></li>
		<li><a href="#section6"><span>Contact</span></a></li>
	</ul>
</div>

<section id="contents">
	<div id="section1">
		<div class="container">
			<div class="section1">
				<h2>Seeing is believing</h2>
			</div>
		</div>
	</div>
	<div id="section2">
		<div class="container">
			<div class="section2">
				<h2>No pain no gain</h2>
			</div>
		</div>
	</div>
	<div id="section3">
		<div class="container">
			<div class="section3">
				<h2>Step by step goes a long way</h2>
			</div>
		</div>
	</div>
	<div id="section4">
		<div class="container">
			<div class="section4">
				<h2>Rome was not built in a day</h2>
			</div>
		</div>
	</div>
	<div id="section5">
		<div class="container">
			<div class="section5">
				<h2>Knowledge in youth is wisdom in age</h2>
			</div>
		</div>
	</div>
	<div id="section6">
		<div class="container">
			<div class="section6">
				<h2>A poet is the painter of the soul</h2>
			</div>
		</div>
	</div>
</section>
            
          
!
            
              /* reset */
* {margin:0; padding:0}
li, ul {list-style:none}
a {text-decoration:none}
.clearfix {*zoom:1}
.clearfix:before, clearfix:after {display:block; content:''; line-height:0}
.clearfix:after {clear:both}
body {font-family: 'Cairo', sans-serif;}

/* nav */
#nav {	
	position: fixed; left: 0; top: 0; z-index:100;
	width: 100%; height: 56px;
	text-align: center;
	transition: top 0.3s ease-in-out;
}
#nav.nav-up {
	top: -80px;
}
#nav li {
	float: left; 
	width: 16.6666%;
}
#nav li a {
	display: block;
	background-color:rgba(255,255,255,0.3);
	color: #fff;
	padding:20px;
}
#nav li.active a {
	background-color:rgba(0,0,0,0.5)
} 

/* dot */
#dot {
	position: fixed;
	right: -100px;
	top: 50%;
	transform: translatey(-50%);
	text-align: right;
	transition: right 0.3s ease-in-out;
}
#dot li a {
	font-size: 18px; 
	padding: 5px;
	width: 5px; height: 5px; background-color:rgba(255,255,255,0.5);
	display: inline-block; border-radius: 50%; 
	border: 3px solid transparent;
	color: #fff;
	transition: all 0.2s ease;
	position: relative;
}
#dot li a span {
	opacity: 0; 
	position: absolute; 
	right: 30px; top: -10px;
}
#dot li.active a {
	border: 3px solid #fff;
}
#dot li.active a span {
	opacity: 1;
}



/* contents */
#contents {text-align: center; }
#contents > div {line-height: 100vh; background-size: cover; background-position: center; background-attachment:fixed; color: #fff; font-size: 40px;}


/* section */
#section1 {background-image: url(http://www.hagoni.com/parallax/assets/img/img4.jpg)}
#section2 {background-image: url(http://www.hagoni.com/parallax/assets/img/img2.jpg)}
#section3 {background-image: url(http://www.hagoni.com/parallax/assets/img/img3.jpg)}
#section4 {background-image: url(http://www.hagoni.com/parallax/assets/img/img1.jpg)}
#section5 {background-image: url(http://www.hagoni.com/parallax/assets/img/img5.jpg)}
#section6 {background-image: url(http://www.hagoni.com/parallax/assets/img/img6.jpg)}
            
          
!
            
              var moveScroll;
var lastScrollTop = "0";
var delta = "5"; //동작의 구현이 시작되는 위치
var navbarHeight = $("#nav").outerHeight();

$(window).scroll(function(event){
	moveScroll = true;
});

setInterval(function(){
	if(moveScroll){
		hasScrolled();
		moveScroll = false;
	}
},250);

function hasScrolled(){
	var wScroll = $(this).scrollTop();	//현재 스크롤 값
	if(Math.abs(lastScrollTop - wScroll) <= delta)
		return;
	if(wScroll > lastScrollTop && wScroll > navbarHeight){
		 //스크롤 내렸을 때 nav-up 생성
		$("#nav").removeClass("nav-down").addClass("nav-up");
		$("#dot").css("right","20px");
	} else {
		 //스크롤 올렸을 때 nav-down 생성
		if(wScroll + $(window).height() < $(document).height()){
			$("#nav").removeClass("nav-up").addClass("nav-down");
			$("#dot").css("right","-100px");
		}
	}
	
	lastScrollTop = wScroll;
};




/* nav메뉴 */
var nav = $("#nav ul li");
var dot = $("#dot ul li");
var contents = $("#contents > div");

nav.click(function(){
	var target = $(this);
	var index = target.index();
	var section = contents.eq(index);
	var offset = section.offset().top;
	$("html,body").animate({scrollTop:offset},600,"easeInOutExpo");
});

dot.click(function(){
	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 > 200){
		$("#nav").addClass("on");
	} else if(wScroll == 0){
		$("#nav").removeClass("on");
	}
	

	if(wScroll >= contents.eq(0).offset().top){
		nav.removeClass("active");
		nav.eq(0).addClass("active");
		dot.removeClass("active");
		dot.eq(0).addClass("active");
	}
	if(wScroll >= contents.eq(1).offset().top){
		nav.removeClass("active");
		nav.eq(1).addClass("active");
		dot.removeClass("active");
		dot.eq(1).addClass("active");
	}
	if(wScroll >= contents.eq(2).offset().top){
		nav.removeClass("active");
		nav.eq(2).addClass("active");
		dot.removeClass("active");
		dot.eq(2).addClass("active");
	}
	if(wScroll >= contents.eq(3).offset().top){
		nav.removeClass("active");
		nav.eq(3).addClass("active");
		dot.removeClass("active");
		dot.eq(3).addClass("active");
	}
	if(wScroll >= contents.eq(4).offset().top){
		nav.removeClass("active");
		nav.eq(4).addClass("active");
		dot.removeClass("active");
		dot.eq(4).addClass("active");
	}
	if(wScroll >= contents.eq(5).offset().top){
		nav.removeClass("active");
		nav.eq(5).addClass("active");
		dot.removeClass("active");
		dot.eq(5).addClass("active");
	}
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console