レスポンシブ対応グローバルナビゲーション

ナビはヘッダ内のピンクの部分。(ページの上部に固定する部分は以下には含んでいません)


<div id="globalNavi">
	<a id="menu"><span class="material-symbols-outlined">menu</span></a>
	<nav>
		<ul>
			<li><a href="/">INDEX</a></li>
			<li><a href="#">CONTENTS 1</a></li>
			<li><a href="#">CONTENTS 2</a></li>
		</ul>
	</nav>
</div>

/*====================================================
*	Navigation
====================================================*/
@media screen and (min-width: 1024px) {
	#globalNavi a#menu {
		display:none;
		}
	#globalNavi nav {
		display: block !important;
		}
	}
#globalNavi {
	width: 100%;
	margin: 0 auto;
	padding: .8rem 0;
	background: rgba(26,25,30,.7);
	overflow:visible;
 	}
#globalNavi ul {
	list-style-type: none;
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;	
	align-content: center;
	}
#globalNavi nav a {
	display: block;
	margin-right: .3rem;
	padding: .5rem 2rem;
	white-space: nowrap;
	text-align: center;
	text-decoration: none;
	color: #fff;
	background: #d02090;
	}
#globalNavi nav a:hover {
	background-color:#f3c1e1;
	text-decoration: none;
	}

/*[ Media Query ] --------------------------- */
@media screen and (max-width: 1023.9px) {
	#globalNavi {
		padding: 0;
		}
	}

/* [Toggle Menu ]
------------------------------------------------ */
@media screen and (max-width: 1023.9px) {
	#globalNavi a#menu {
		display: block;
		text-align: right;
		margin:0;
		padding: 1rem 2rem 0 0;
		color:#fff;
		background-color:#d02090;
		}
	#globalNavi a#menu span {
		font-size: 4rem;
		line-height: ;
		letter-spacing: .2rem;
		}
	#globalNavi a#menu:hover {
		color: #ff0;
		text-decoration: none;
		background-color:#f698d4;
		color:#d02090;
		}
	#globalNavi ul {
		display: block;
		justify-content: center;
		}
	#globalNavi nav a {
		padding: 1.5rem 2rem;
		color:#d02090;
		background-color:#fff;
		border-bottom:1px #134192 dashed;
		}
		#globalNavi ul li:first-child a {
			border-top:1px #fff dashed;
			}
	}

//スマホ用ナビゲーションスライドダウン
$(function () {
	$("#globalNavi nav").hide();
	$("#menu").click(function () {
		$(this).toggleClass("menuOpen").next().slideToggle();
	});
})

TOP