Home>

https://coliss.com/articles/build-websites/operation/css/css-only-responsive-navigation-luxbar.html

This style sheet is used to create a responsive menu.
I was able to implement it, but when I opened the menu on my smartphone
If it is an in-page link, the menu screen will not close.

Can jQuery be used to close it?
In addition, please tell me what kind of description should be given.

・ HTML menu part

<header>
    <input type = "checkbox" />
    <div>
        <ul>
            <li>
                <a href = "#"><img src = "img/sanrio_logo.png"></a>
                <label
                for = "luxbar-checkbox"><span></span></label>
            </li>
            <li><a href = "# menu1">MENU1</a></li>
            <li><a href = "# menu2">MENU2</a></li>
            <li><a href = "# menu3">MENU3</a></li>
            <li><a href = "# menu4">MENU4</a></li>
            <li><a href = "# menu5">MENU5</a></li>
        </ul>
    </div>
</header>

<div>
     Contains content.
</div>
<div>
     Contains content.
</div>
<div>
     Contains content.
</div>
<div>
     Contains content.
</div>
<div>
     Contains content.
</div>

-Menu part CSS

.luxbar-default {
  width: 100%;
  position: relative;
  box-shadow: 0 1px 3px rgba (0, 0, 0, 0.12), 0 1px 2px rgba (0, 0, 0, 0.24);
.luxbar-static {
  box-shadow: 0 1px 3px rgba (0, 0, 0, 0.12), 0 1px 2px rgba (0, 0, 0, 0.24);
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;}
  .luxbar-static .luxbar-checkbox: checked ~ .luxbar-menu {
    position: absolute;}
.luxbar-fixed {
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba (0, 0, 0, 0.12), 0 1px 2px rgba (0, 0, 0, 0.24);
.luxbar-fixed-bottom {
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba (0, 0, 0, 0.12), 0 1px 2px rgba (0, 0, 0, 0.24);
.luxbar-hamburger span, .luxbar-hamburger span :: before, .luxbar-hamburger span :: after {
  display: block;
  height: 2px;
  width: 26px;
  transition: 0.6s ease;
.luxbar-checkbox: checked ~ .luxbar-menu li .luxbar-hamburger span {
  background-color: transparent;}
  .luxbar-checkbox: checked ~ .luxbar-menu li .luxbar-hamburger span :: before, .luxbar-checkbox: checked ~ .luxbar-menu li .luxbar-hamburger span :: after {
    margin-top: 0;}
.luxbar-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  height: 65px;
  text-align: left;
  padding-left: 10px;
  }
.luxbar-menu-left .luxbar-navigation, .luxbar-menu-left .luxbar-header {
  justify-content: flex-start;
.luxbar-menu-right .luxbar-hamburger {
  margin-left: auto;}
.luxbar-brand {
  padding-right: 10px;
 }
.luxbar-menu {
  min-height: 58px;
  transition: 0.6s ease;
  width: 100%;}
.luxbar-navigation {
  display: flex;
  flex-direction: column;
  list-style: none;
  padding-left: 0;
  margin: 0;
text-align: right;}
.luxbar-menu a,
.luxbar-item a {
  text-decoration: none;
  color: inherit;
  cursor: pointer;}.luxbar-item {
  height: 58px;}
  .luxbar-item a {
    padding: 18px 9px 18px 9px;
    display: block;
    line-height: 98%;
   }
.luxbar-hamburger {
  padding: 18px 24px 18px 24px;
  position: relative;
  cursor: pointer;}
  .luxbar-hamburger span :: before, .luxbar-hamburger span :: after {
    content: '';
    position: absolute;}
  .luxbar-hamburger span :: before {
    margin-top: -8px;}
  .luxbar-hamburger span :: after {
    margin-top: 8px;}
.luxbar-checkbox {
  display: none;}
  .luxbar-checkbox: not (: checked) ~ .luxbar-menu {
    overflow: hidden;
    height: 58px;}
  .luxbar-checkbox: checked ~ .luxbar-menu {
    transition: height 0.6s ease;
    height: 100vh;
    overflow: auto;
   }
.dropdown {
  position: relative;
  height: auto;
  min-height: 58px;
  .dropdown: hover>ul {
    position: relative;
    display: block;
    min-width: 100%;}
  .dropdown>a :: after {
    position: absolute;
    content: '';
    right: 10px;
    top: 25px;
    border-width: 5px 5px 0;
    border-color: transparent;
    border-style: solid;}
  .dropdown>ul {
    display: block;
    overflow-x: hidden;
    list-style: none;
    padding: 0;}
    .dropdown>ul .luxbar-item {
      min-width: 100%;
      height: 29px;
      padding: 5px 10px 5px 40px;
      .dropdown>ul .luxbar-item a {
        min-height: 29px;
        line-height: 29px;
        padding: 0;}
@media screen and (min-width: 767px) {
  .luxbar-navigation {
    flex-flow: row;
    justify-content: flex-end;
    text-align: left;}
  .luxbar-hamburger {
    display: none;}
  .luxbar-checkbox: not (: checked) ~ .luxbar-menu {
    overflow: visible;}
  .luxbar-checkbox: checked ~ .luxbar-menu {
    height: 58px;}
  .luxbar-menu .luxbar-item {
    border-top: 0;}
  .luxbar-menu-right .luxbar-header {
    margin-right: auto;}
  .dropdown {
    height: 58px;}
    .dropdown: hover>ul {
      position: absolute;
      left: 0;
      top: 58px;
      padding: 0;}
    .dropdown>ul {
      display: none;}
      .dropdown>ul .luxbar-item {
        padding: 5px 10px;}
        .dropdown>ul .luxbar-item a {
          white-space: nowrap;}}
.luxbar-checkbox: checked + .luxbar-menu .luxbar-hamburger-doublespin span :: before {
  transform: rotate (225deg);}
.luxbar-checkbox: checked + .luxbar-menu .luxbar-hamburger-doublespin span :: after {
  transform: rotate (-225deg);}
.luxbar-checkbox: checked + .luxbar-menu .luxbar-hamburger-spin span :: before {
  transform: rotate (45deg);}
.luxbar-checkbox: checked + .luxbar-menu .luxbar-hamburger-spin span :: after {
  transform: rotate (-45deg);}
/ ******* color variables ******* /
/ ******* default dark ******* /
.luxbar-menu-dark,
.luxbar-menu-dark .dropdown ul {
  background-color: rgba (0,0,0,0.5);
  color: #fff;
   }
.luxbar-menu-dark .active,
.luxbar-menu-dark .luxbar-item: hover {
color: # a2b4b7;}
.luxbar-menu-dark .luxbar-hamburger span,
.luxbar-menu-dark .luxbar-hamburger span :: before,
.luxbar-menu-dark .luxbar-hamburger span :: after {
  background-color: #fff;}

Because it was a responsive navigation created with CSS only, there was no js.

  • Answer # 1

    What about jQuery?

    $(function () {
      $('. luxbar-item a'). on ('click', function (event) {
        $('# luxbar-checkbox'). prop ('checked', false);
      });
    });

Related articles