時時腕時計(ときどき、うでどけい)

趣味で集めた古い腕時計や日々の出来事を綴るブログです。

グローバルメニューの設置

書き散らかした記事を見やすくするために、グローバルメニューを設置しました。
メニューからカテゴリやサブカテゴリを選択することで記事の絞り込みが行えます。

グローバルメニュー設置前

f:id:oto-man:20200405233058j:plain

グローバルメニュー設置後(PC画面表示)

f:id:oto-man:20200405233325p:plain
タイトル下のグレーのバーがグローバルメニューです。

グローバルメニュー設置後(スマホ画面表示)

f:id:oto-man:20200405233928p:plain
画面が狭いスマホの場合は右上に横三本線のメニューアイコンを表示させます。
これをクリックするとプルダウンが表示されます。
f:id:oto-man:20200405234059p:plain

HTMLコード

「設定」-「デザイン」-「カスタマイズ」-「ヘッダ」の「タイトル下」に以下のコードを貼り付けます。

<div class="drawer_menu">
	<!-- コピーライト消さないように!
		Zarigani Design Office Drawer Menu
		Copyright 2018 Zarigani Design Office
                Customized by minimalgreen

		Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

		The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

		THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
		コピーライトここまで -->

	<div class="drawer_bg"></div>

	<button type="button" class="drawer_button">
		<span class="drawer_bar drawer_bar1"></span>
		<span class="drawer_bar drawer_bar2"></span>
		<span class="drawer_bar drawer_bar3"></span>
		<span class="drawer_menu_text drawer_text">MENU</span>
		<span class="drawer_close drawer_text">CLOSE</span>
	</button>

	<nav class="drawer_nav_wrapper">
		<ul class="drawer_nav">
			<li>
				<a href="https://blog.oto-man.work/">HOME</a>
			</li>
			<li>
				<a href="https://blog.oto-man.work/archive/category/%E8%85%95%E6%99%82%E8%A8%88">腕時計</a>
				<span class="touch-btn"><i class="blogicon-chevron-down lg"></i></span>
				<ul class="second-level">
					<li>
						<a href="https://blog.oto-man.work/archive/category/SEIKO">SEIKO</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/CITIZEN">CITIZEN</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/ORIENT">ORIENT</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/RICOH">RICOH</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/OMEGA">OMEGA</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/RADO">RADO</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/%E3%81%9D%E3%81%AE%E4%BB%96%E3%83%A1%E3%83%BC%E3%82%AB%E3%83%BC">その他メーカー</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/%E6%8A%80%E8%A1%93%E6%83%85%E5%A0%B1">技術情報</a>
					</li>
				</ul>
			</li>
			<li>
				<a href="%E8%B6%A3%E5%91%B3">趣味</a>
				<span class="touch-btn"><i class="blogicon-chevron-down lg"></i></span>
				<ul class="second-level">
					<li>
						<a href="https://blog.oto-man.work/archive/category/%E9%9F%B3%E6%A5%BD">音楽</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/%E6%98%A0%E7%94%BB">映画</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/%E6%9B%B8%E7%B1%8D">書籍</a>
					</li>
				</ul>
			</li>
			<li>
				<a href="https://blog.oto-man.work/archive/category/%E6%97%A5%E5%B8%B8">日常</a>
				<span class="touch-btn"><i class="blogicon-chevron-down lg"></i></span>
				<ul class="second-level">
					<li>
						<a href="https://blog.oto-man.work/archive/category/%E8%87%AA%E7%84%B6">自然</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/%E7%94%9F%E6%B4%BB">生活</a>
					</li>
				</ul>
			</li>
			<li>
				<a href="https://blog.oto-man.work/archive/category/%E3%83%91%E3%82%BD%E3%82%B3%E3%83%B3">パソコン</a>
				<span class="touch-btn"><i class="blogicon-chevron-down lg"></i></span>
				<ul class="second-level">
					<li>
						<a href="https://blog.oto-man.work/archive/category/%E3%83%96%E3%83%AD%E3%82%B0%E8%A8%AD%E5%AE%9A">ブログ設定</a>
					</li>
					<li>
						<a href="https://blog.oto-man.work/archive/category/%E4%BE%BF%E5%88%A9%E3%81%AA%E3%82%BD%E3%83%95%E3%83%88">便利なソフト</a>
					</li>
				</ul>
			</li>
			<li>
				<a href="https://blog.oto-man.work/archive/category/%E3%81%9D%E3%81%AE%E4%BB%96">その他</a>
			</li>
		</ul>
	</nav>
</div>

<!-- jQuery読み込み -->
<script src="https://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
<script>
$(function () {

	$('.drawer_button').click(function () {
		$(this).toggleClass('active');
		$('.drawer_bg').fadeToggle();
		$('nav').toggleClass('open');
	})
	$('.drawer_bg').click(function () {
		$(this).fadeOut();
		$('.drawer_button').removeClass('active');
		$('nav').removeClass('open');
	});
	$(".touch-btn").on("click", function () {
		$(this).next().slideToggle();
	});
})
</script>

CSSコード

/*
Zarigani Design Office Drawer Menu
Copyright 2018 Zarigani Design Office
Customized by minimalgreen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

.drawer_menu a {
	color: inherit;
	text-decoration: none;
}

.drawer_menu a:visited {
	color: inherit;
}


/* PC用ナビゲーション */

.drawer_menu .drawer_nav_wrapper {
	transform: translate(0);
	width: 100%;
	height: 50px;
	/* PC用メニュー高さ */
	position: relative;
	top: auto;
	right: auto;
	z-index: 100;
	background-color: #555;
	/* PC用メニュー背景色 */
}

.drawer_menu .drawer_nav {
	max-width: 1000px;
	/* コンテンツ幅に合わせる */
	padding: 0;
	margin: 0 auto;
	display: -webkit-flex;
	display: flex;
	-webkit-justify-content: center;
	justify-content: center;
	list-style-type: none;
}

.drawer_menu .drawer_nav li {
	font-size: 16px;
	margin: 0;
	padding: 0;
	width: 100%;
	height: 50px;
	/* PC用メニュー高さ */
	line-height: 50px;
	/* PC用メニュー高さ */
	background-color: #555;
	/* PC用メニューボタン背景色 */
	text-align: center;
	list-style-type: none;
}

.drawer_menu .drawer_nav li:hover {
	background-color: #999;
	/* PC用メニューボタンマウスオーバー背景色 */
}

.drawer_menu .drawer_nav li a {
	color: #fff;
	/* PC用メニューボタン文字色 */
}


/* PC非表示 */

@media screen and (min-width:1001px) {
	.pc-hidden {
		display: none;
		text-align: center;
	}
}

@media screen and (min-width: 1001px) {

	/* ドロップダウンメニュー2階層目 */
	.drawer_menu .drawer_nav li ul.second-level {
		visibility: hidden;
		list-style-type: none;
		position: absolute;
		z-index: -1;
		top: 0;
		margin: 0;
		padding-left: 0;
	}

	.drawer_menu .drawer_nav li:hover ul.second-level {
		visibility: visible;
		z-index: 1;
		top: 50px;
		/* PC用メニューの高さに合わせる */
		transition: all .3s;
	}

	.drawer_menu .drawer_nav li:hover ul.second-level li {
		width: 200px;
		/* ドロップダウンメニューボタン横幅 */
		height: 50px;
		/* Pドロップダウンメニューボタン高さ */
		text-align: center;
	}

	.drawer_menu .drawer_nav li:hover ul.second-level li a {
		display: block;
		background-color: #555;
		/* ドロップダウンメニューの文字の背景色 */
		color: #fff;
		/* ドロップダウンメニューの文字色 */
		font-size: 100%;
		text-decoration: none;
		line-height: 50px;
		/* Pドロップダウンメニューボタン高さ */
		text-align: center;
	}

	.drawer_menu .drawer_nav li:hover ul.second-level li a:hover {
		background-color: #999;
		/* ドロップダウンメニューマウスホバー背景色 */
	}

	.touch-btn {
		color: #fff;
		margin-left: 5px;
	}
}

/*+++ Default Button Color +++*/

.drawer_menu .drawer_button {
	color: #fff;
	/* ハンバーガーメニュー文字色 */
	display: none;
}

.drawer_menu .drawer_button .drawer_bar {
	background-color: #fff;
	/* ハンバーガーメニュー三本線の色 */
}


/* 1000px以下 */

@media screen and (max-width: 1000px) {
	.drawer_menu .drawer_bg {
		width: 100%;
		height: 100%;
		position: fixed;
		z-index: 999;
		background-color: rgba(51, 51, 51, 0.5);
		display: none;
		top: 0;
		left: 0;
	}

	.drawer_menu .drawer_button {
		display: block;
		background-color: #555;
		color: #fff;
		border: none;
		padding: 5px;
		width: 50px;
		letter-spacing: 0.1em;
		cursor: pointer;
		position: fixed;
		top: 10px;
		right: 10px;
		z-index: 1001;
		text-align: center;
		outline: none;
	}

	.drawer_menu .drawer_button.active .drawer_bar {
		width: 40px;
	}

	.drawer_menu .drawer_button.active .drawer_bar1 {
		transform: rotate(30deg);
	}

	.drawer_menu .drawer_button.active .drawer_bar2 {
		opacity: 0;
	}

	.drawer_menu .drawer_button.active .drawer_bar3 {
		transform: rotate(-30deg);
	}

	.drawer_menu .drawer_button.active .drawer_menu_text {
		display: none;
	}

	.drawer_menu .drawer_button.active .drawer_close {
		display: block;
	}

	.drawer_menu .drawer_bar {
		display: block;
		height: 2px;
		margin: 8px 2px;
		transition: all 0.2s;
		transform-origin: 0 0;
	}

	.drawer_menu .drawer_text {
		text-align: center;
		font-size: 10px;
	}

	.drawer_menu .drawer_close {
		letter-spacing: 0.08em;
		display: none;
	}

	.drawer_menu .drawer_menu_text {
		display: block;
	}

	.drawer_menu .drawer_nav_wrapper {
		width: 250px;
		height: 100%;
		transition: all 0.2s;
		transform: translate(250px);
		position: fixed;
		top: 0;
		right: 0;
		z-index: 1000;
		background-color: #FFF;
		/* ドロワーメニュー内背景色 */
		overflow-x: hidden;
		overflow-y: auto;
	}

	.drawer_menu .drawer_nav {
		display: block;
		position: relative;
		margin-top: 40px;
	}

	.drawer_menu .drawer_nav li {
		background-color: #fff;
		height: auto;
		line-height: 50px;
		/*  ドロワーメニューリスト項目高さ */
		position: relative;
		border-bottom: 1px solid #eee;
	}

	.drawer_menu .drawer_nav li a {
		background-color: #fff;
		/* ドロワーメニューリスト背景色 */
		color: #555;
		/* ドロワーメニューリスト文字色 */
		display: block;
		text-align: left;
		padding-left: 20px;
	}

	/* スマートフォン2階層目 */
	.drawer_menu .drawer_nav li:hover ul.second-level {
		display: block;
	}

	.drawer_menu .drawer_nav li ul.second-level {
		display: none;
		position: relative;
		padding: 0;
		z-index: 1001;
	}

	.drawer_menu .drawer_nav li ul.second-level li a {
		padding-left: 40px;
	}

	.drawer_menu .drawer_nav_wrapper.open {
		transform: translate(0);
	}

	.drawer_menu.left .drawer_button {
		right: auto;
		left: 32px;
	}

	.drawer_menu.left .drawer_nav_wrapper {
		transform: translate(-250px);
		right: auto;
		left: 0;
	}

	.drawer_menu.left .drawer_nav_wrapper.open {
		transform: translate(0);
	}

	.pc-hidden {
		text-align: center;
	}

	.touch-btn {
		color: #555;
		position: absolute;
		top: .25rem;
		right: 2%;
		display: block;
		z-index: 10;
		width: 50px;
		height: 50px;
		text-align: center;
		vertical-align: middle;
	}
}

/*  ウィジェットタイトル */
.drawer-title {
	text-align: center;
	width: 100%;
	height: 50px;
	line-height: 50px;
	background-color: #555;
	/* ドロワーメニュー内タイトルライン背景色 */
	color: #fff;
}

/* フォローボタン */

.follow-buttons {
	text-align: center;
	margin-top: 0;
	width: 100%;
}

.follow-buttons a {
	display: inline-block;
	width: 60px;
	text-align: center;
	text-decoration: none;
	margin: 5px;
}

.follow-buttons .inner-text {
	font-size: 10px;
	display: block;
}

.follow-buttons .lg,
.content-inner-follow-buttons .fa {
	padding: 15px;
	border-radius: 5px;
	margin: 2px auto;
}

.follow-buttons .hatena {
	color: #38393C;
	background-color: transparent;
}

.follow-buttons .blogicon-hatenablog {
	background: #38393C;
	color: #ffffff;
}

.follow-buttons .blogicon-hatenablog:hover {
	background: #5F6063;
}

.follow-buttons .facebook {
	color: #305097;
	background-color: transparent;
}

.follow-buttons .blogicon-facebook {
	background: #305097;
	color: #ffffff;
}

.follow-buttons .blogicon-facebook:hover {
	background: #5A77B7;
}

.follow-buttons .twitter {
	color: #55acee;
	background-color: transparent;
}

.follow-buttons .blogicon-twitter {
	background: #55acee;
	color: #ffffff;
}

.follow-buttons .blogicon-twitter:hover {
	background: #89C7F7;
}

.follow-buttons .instagram {
	color: #D93177;
	background-color: transparent;
}

.follow-buttons .blogicon-instagram {
	background: #D93177;
	color: #ffffff;
}

.follow-buttons .blogicon-instagram:hover {
	background: #df528d;
}

.follow-buttons .feedly {
	color: #6cc655;
	background-color: transparent;
}

.follow-buttons .blogicon-rss {
	background: #6cc655;
	color: #ffffff;
}

.pc-hidden .profile-icon {
	float: none;
}

謝辞

メニューの設置について、先輩サイト様の情報を参照させていただきました。
blog.minimal-green.com