サブメニューがドロップするナビ・1


<div id="drop-globalBox">
	<a id="drop-menu"><span class="material-symbols-outlined">menu</span><span>MENU</span></a>
	<nav id="drop-globalNav">
		<ul id="dropNav">
			<li><a href="/">HOME</a></li>

			<li><a href="AAA.html">AAAAAA</a>
				<ul>
					<li><a href="AAA.html#A01">A01</a></li>
					<li><a href="AAA.html#A02">A02</a></li>
				</ul>
			</li>
				・・・
			<li><a href="DDD.html">DDDDDDDDD</a>
				<ul>
					<li><a href="DDD.html#D01">D01</a></li>
					<li><a href="DDD.html#D02">D02</a></li>
					<li><a href="DDD.html#D03">D03</a></li>
					<li><a href="DDD.html#D04">D04</a></li>
				</ul>
			</li>
		</ul>
	</nav>
</div>

/*----------------------------------------------------------------------
  ■ Navigation Base
----------------------------------------------------------------------*/
#drop-globalBox {
	padding: 0;
	background-color: rgba(51,51,51,.5);
	}
#drop-globalNav a {
	display: block;
	margin: 0 1px;
	padding: .8rem 2.5rem;
	text-align: center;
	text-decoration: none;
	white-space: nowrap;
	background-color: rgba(51,51,51,.5);
	color: #fff;
	}
#drop-globalNav a:hover {
	background: rgba(154,205,50,1);
	color: #333;
	}

/* [Base navi]------------------------------------------------ */
@media screen and (min-width: 769px) {
	#drop-globalBox a#drop-menu {
		display: none;
		}
	#drop-globalNav {
		display: block !important;
		}
	}

#drop-globalNav {
	position:relative;
	z-index: 300;
	padding: 0;
	}
#drop-globalNav > ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;	
	align-item: center;
	margin: 1px;
	padding: 0;
	list-style-type: none;
	}
#drop-globalNav > ul > li {
	display: block;
	margin: 0;
	padding: 0;
	}
#drop-globalNav > ul > li a {
	background-color: rgba(51,51,51,.8);
	color: #fff;
	}

/* [Toggle Menu]------------------------------------------------ */
@media screen and (max-width: 768px) {
	#drop-globalBox a#drop-menu {
		display: block;
		}
	#drop-globalNav > ul {
		flex-direction: column;
		justify-content: center;
		}
	#drop-globalNav > ul ul {
		display: none;
		}

	#drop-globalBox a#drop-menu {
		padding: .5rem;
		text-align: center;
		text-decoration: none;
		color: #fff;
		background-color: rgba(51,51,51,.8);
		}
	#drop-globalBox a#drop-menu:hover {
		color: #ff0;
		background-color: rgba(51,51,51,.7);
		}
	#drop-globalBox a#drop-menu .material-symbols-outlined {
		vertical-align: -5px;
		}
	#drop-globalNav > ul > li a {
		background-color: rgba(51,51,51,.3);
		border-bottom: 1px #fff dotted !important;
		}

	#drop-globalNav > ul > li:hover ul {
		display: block;
		position:relative;
		width: 100%;
		top: 100%;
		}
	#drop-globalNav > ul > li:hover ul li {
		width: 100%;
		}
	#drop-globalNav > ul > li:hover {
			position:relative;
		}
	}

/* [Drop menu]------------------------------------------------ */
@media screen and (min-width: 769px) {
	#drop-dropNav > li {
		position: relative;
		margin: 0;
		padding: 0;
		}
	#drop-dropNav > li a {
		text-align: left;
		}
	}

#drop-dropNav > li ul {
	position: absolute;
	top: 100%;
	right: 0;
	margin: 0;
	padding: 0;
	background-color: rgba(255,255,255,1);
	}

#drop-dropNav > li ul li {
	overflow: hidden;
	height: 0px;
	transition: .2s;
	}
#drop-dropNav > li:hover ul li {
	overflow: visible;
	width: 15em;
	height: 4.3rem;
	margin: 0;
	padding: 0;
	}
#drop-globalNav > ul > li a {
	border-bottom: 1px #fff dotted !important;
	}

@media screen and (max-width: 768px) {
	#drop-globalNav > ul ul {
		display: none;
		}
	#drop-globalNav > ul:hover ul {
		display: block;
		}
	}

※以下はスマホなどの幅狭画面時のトグルナビ用なのでドロップダウンナビには必要なしです。

$(function () {
	$("#drop-globalNav").hide();
	$("#drop-menu").click(function () {
		$(this).toggleClass("menuOpen").next().slideToggle();
	});
});


TOP