<header class="header">
    <div class="header__layout">
      <h1 id="hamburger-logo" class="header__logo">
        <a href="#">ここにロゴ</a>
      </h1>
      <div id="hamburger-nav" class="header__nav">
        <ul class="header__menus">
          <li class="header__menu">
            <a href="#">メニュー</a>
          </li>
          <li class="header__menu">
            <a href="#">メニュー</a>
          </li>
          <li class="header__menu">
            <a href="#">メニュー</a>
          </li>
          <li class="header__menu">
            <a href="#">メニュー</a>
          </li>
        </ul>
      </div>
      <div id="hamburger" class="hamburger">
        <div id="hamburger-icon" class="hamburger__icon">
          <div class="hamburger__bar"></div>
          <div class="hamburger__bar"></div>
          <div class="hamburger__bar"></div>
        </div>
      </div>
    </div>
  </header>
/* リセットCSS */
a {
	color: inherit;
	text-decoration: none;
}

ul {
  margin: 0;
	padding: 0;
	list-style: none;
}

/* ヘッダーで使用 */
.header {
	position: fixed;
	z-index: 10;
	top: 0;
	left: 0;
	width: 100%;
	height: 100px;
	background-color: black;
}

.header__layout {
	display: flex;
	justify-content: space-between;
	align-items: center;
	height: inherit;
	margin: 0 auto;
	padding: 0 20px;
}

.header__logo {
	position: relative;
	z-index: 12;
}

.header__logo a {
	font-size: 24px;
  color: #fff;
	transition: all 0.3s;
}

.header__logo a:hover {
	opacity: 0.7;
}

.header__nav {
	height: inherit;
}

.header__menus {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 40px;
	height: inherit;
}

.header__menu {
	height: inherit;
}

.header__menu a {
	display: flex;
	align-items: center;
	justify-content: center;
	height: inherit;
  font-size: 18px;
  color: #fff;
	transition: all 0.3s;
}

.header__menu a:hover {
	color: #ffe100;
}

/* ハンバーガーメニュー関連 */
.hamburger {
  display: none;
}
 
@media screen and (max-width: 767px) {
  .hamburger {
    display: block;
  }
  
  .header__menus {
    position: fixed;
    z-index: 12;
    top: 100px;
    right: -120%;
    width: 100%;
    height: calc(100% - 100px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #000;
    transition: all 0.6s;
  }
  
  .header__menu {
    width: 100%;
    height: auto;
  }
  
  .header__menu a {
    height: auto;
 }
}

.hamburger__icon {
	cursor: pointer;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	width: 40px;
	height: 32px;
}

.hamburger__icon:hover .hamburger__bar {
	background-color: #ffe100;
}

.hamburger__icon .hamburger__bar {
	background-color: #fff;
	border-radius: 2px;
	width: 100%;
	height: 3px;
	transition: all 0.3s;
}

/* ハンバーガーメニューのアニメーション */
.js-hamburger {
  display: block;
 }

/* ハンバーガーメニューのメニューで使用 */
.js-hamburger-nav .header__menus {
	right: 0;
}

/* ハンバーガーメニューのアイコンで使用 */
.js-hamburger .hamburger__icon {
	position: relative;
	z-index: 12;
}

.js-hamburger .hamburger__icon .hamburger__bar {
	position: absolute;
}

.js-hamburger .hamburger__icon .hamburger__bar:nth-child(1) {
	left: 0;
	top: calc(50% - 1px);
	transform: rotate(45deg);
}

.js-hamburger .hamburger__icon .hamburger__bar:nth-child(2) {
	opacity: 0;
}

.js-hamburger .hamburger__icon .hamburger__bar:nth-child(3) {
	bottom: calc(50% - 2px);
	left: 0;
	transform: rotate(-45deg);
}

/* ハンバーガーメニューを開いた時に背景を固定する */
.js-background-fixed {
	height: 100%;
	overflow: hidden;
	width: 100%;
}
$(function(){
  const bodyElement = $("body");
  const hamburger = $('#hamburger');
  const hamburger_logo = $('#hamburger-logo');
  const hamburger_icon = $('#hamburger-icon');
  const hamburger_nav = $('#hamburger-nav');
  const hamburger_menu = $('#hamburger-nav a');

  hamburger_icon.on('click', function() {
    hamburger.toggleClass('js-hamburger');
    hamburger_nav.toggleClass('js-hamburger-nav');
    bodyElement.toggleClass('js-background-fixed');
  });

  hamburger_logo.on('click', function() {
    hamburger.removeClass('js-hamburger');
    hamburger_nav.removeClass('js-hamburger-nav');
    bodyElement.removeClass('js-background-fixed');
  });

  hamburger_menu.on('click', function() {
    hamburger.removeClass('js-hamburger');
    hamburger_nav.removeClass('js-hamburger-nav');
    bodyElement.removeClass('js-background-fixed');
  });

  $(window).resize(function() {
    var windowWidth = $(window).width();

    if (windowWidth >= 768) {
      hamburger.removeClass('js-hamburger');
      hamburger_nav.removeClass('js-hamburger');
      bodyElement.removeClass('js-background-fixed');
    }
  });
 });

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js