Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <header>
	<nav class="g-nav">
		<ul class="g-nav-menu">
			<li>HOME</li>
			<li>ABOUT</li>
			<li>CONTCT</li>
		</ul>
	</nav>
</header>

<section id="sec01">
	<p>コンテンツ1</p>
</section>
	
	<section id="sec02">
	<p>コンテンツ2</p>
</section>
	
	<section id="sec03">
	<p>コンテンツ3</p>
</section>
              
            
!

CSS

              
                	header{
		background: #155263;
		position: relative;
    width: 100%;
	}
	.g-nav{
		width: 100%;
		z-index: 10;
	}
	.g-nav-menu{
		text-align: center;
	}
	.g-nav-menu li{
		color: #fff;
		padding: 0 30px;
		list-style-type: none;
		display: inline-block;
		line-height: 80px;
	}
	.fixed{
		position: fixed;
		top: 0;
		left: 0;
	}
	.fixed .g-nav-menu li{
		line-height: 40px;
	}
	section{
		display: table;
		width: 100%;
		height: 800px;
		text-align: center;
	}
	section p{
		display: table-cell;
		vertical-align: middle;
		color: #fff;
	}
	#sec01{
		background: #FF6F3C;
	}
	#sec02{
		background: #FF9A3C;
	}
	#sec03{
		background: #FFC93C;
	}
              
            
!

JS

              
                $(function() {
	var headNav = $("header");
	//scrollだけだと読み込み時困るのでloadも追加
	$(window).on('load scroll', function () {
		//現在の位置が500px以上かつ、クラスfixedが付与されていない時
		if($(this).scrollTop() > 500 && headNav.hasClass('fixed') == false) {
			//headerの高さ分上に設定
			headNav.css({"top": '-100px'});
			//クラスfixedを付与
			headNav.addClass('fixed');
			//位置を0に設定し、アニメーションのスピードを指定
			headNav.animate({"top": 0},600);
		}
		//現在の位置が300px以下かつ、クラスfixedが付与されている時にfixedを外す
		else if($(this).scrollTop() < 300 && headNav.hasClass('fixed') == true){
			headNav.removeClass('fixed');
		}
	});
});
              
            
!
999px

Console