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 id="site-header">
    <h1 id="site-logo">logo</h1>
</header>

<main id="main">
</main>
              
            
!

CSS

              
                /* Google FontsからNoto Sansを読み込む */
@import url('https://fonts.googleapis.com/css?family=Noto+Sans');

/* ヘッダ */
header {
	overflow: hidden;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	z-index: 100;
	background-color: #00a8ff;
	text-align: center;
	transition: height 0.3s;
	/* サイトロゴ */
	h1#site-logo {
		line-height: 1.5;
		font-size: 5rem;
		font-family: 'Noto Sans', sans-serif;
		color: #fff;
		transition: all 0.3s;
	}
	/* 縮小時のサイトロゴ */
	&.smaller {
		h1#site-logo {
			line-height: 1;
			font-size: 2rem;
		}
	}
}

/* メインカラム */
#main {
	height: 20000px;
}
              
            
!

JS

              
                // 何ピクセルスクロールしたらヘッダを変化させるか
var px_page_y   = 300;
// HEADER要素の取得
var header = document.getElementById( "site-header" );

// スクロールのイベントハンドラを登録
window.addEventListener( "scroll" , function(e){
	// 変化するポイントまでスクロールしたかを判定
	if ( window.pageYOffset > px_page_y ) {
		// クラスを追加
		header.classList.add( "smaller" );

	// スクロール位置が変化するポイント以前で、さらにsmallerクラスがあるか判定
	} else if ( header.classList.contains( "smaller" ) ) {
		// クラスを削除
		header.classList.remove( "smaller" );
	}
} );

              
            
!
999px

Console