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

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <header class="header">
	<h1 class="logo">Navigation</h1>
	<nav class="global-nav">
		<ul>
			<li><a href="#">NEWS</a></li>
			<li><a href="#">ABOUT</a></li>
			<li><a href="#">ACCESS</a></li>
			<li><a href="#">CONTACT</a></li>
		</ul>
	</nav>
	<a href="#" class="open-button"></a>
</header><!-- // #header -->

            
          
!
            
              ul,li{
	margin: 0;
	padding: 0;
	list-style: none;
}
.header{
	overflow: hidden;
}
.logo{
	margin: 10px;
}

//ナビクローズ時のスタイル
.global-nav {
	background: #efefef;
	transform-origin: center top;
	transform: translateX(100%);
	transition: transform .5s;
	overflow: hidden;
	li{
		a{
		  display: block;
		  padding: 10px 15px;
			color: black;
			&:hover{
				text-decoration: none;
			}
		}
	}
}

.open-button {
	display: block;
	width: 50px;
	height: 50px;
	position: fixed;
	top: 10px;
	right: 10px;
	line-height: 2.9em;
	background-color: pink;
	text-align: center;
	&::before{
		content: 'menu';
	}
}

//ナビオープン時のスタイル
.nav-open{
	.global-nav {
		overflow: hidden;
		transform: translateX(80%);
		li:hover{
			background-color: #ccc;
		}
	}
	.open-button::before{
		content: 'close';
	}
}
            
          
!
            
              $(function() {
    var settings = {
        targetSelector : 'body', // オープン時にclassを付け外しする対象
        openClass : 'nav-open', // オープン時に付与するclass名
        navSelector : '.global-nav', // ナビゲーションのCSSセレクター
        buttonSelector : '.open-button', // 開閉ボタンのCSSセレクター
        fade : false, //フェードイン、アウトするか
        fadeSpeed : 400, //フェードイン、アウトの速度(1000=1秒)
    };

    $(settings.buttonSelector).removeAttr('href').css('cursor', 'pointer').on('click', function(event) {
        var $target = $(settings.targetSelector);
        var $gNav = $(settings.navSelector);
        $target.toggleClass(settings.openClass);
        if($target.hasClass(settings.openClass)) {
          if(settings.fade) $gNav.fadeIn(settings.fade);
        } else {
          if(settings.fade) $gNav.fadeOut(settings.fade);
        }
    });
    if(settings.fade) $(settings.navSelector).css('display', 'none');
});


            
          
!
999px
Loading ..................

Console