html menu.html

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html menu.html相关的知识,希望对你有一定的参考价值。

/* Remove margins and padding from the list, and add a black background color */
ul.topnav {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333333;
}

/* Float the list items side by side */
ul.topnav li {
  float: left;
}

/* Style the links inside the list items */
ul.topnav li a {
  display: inline-block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  transition: 0.3s;
  font-size: 17px;
}

/* Change background color of links on hover */
ul.topnav li a:hover {
  background-color: #111111;
}

/* Hide the list item that contains the link that should open and close the topnav on small screens */
ul.topnav li.icon {
  display: none;
}

/* When the screen is less than 680 pixels wide, hide all list items, except for the first one ("Home"). Show the list item that contains the link to open and close the topnav (li.icon) */
@media screen and (max-width:680px) {
  ul.topnav li:not(:first-child) {display: none;}
  ul.topnav li.icon {
    float: right;
    display: inline-block;
  }
}

/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens */
@media screen and (max-width:680px) {
  ul.topnav.responsive {position: relative;}
  ul.topnav.responsive li.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  ul.topnav.responsive li {
    float: none;
    display: inline;
  }
  ul.topnav.responsive li a {
    display: block;
    text-align: left;
  }
}
/**
 * Menu Responsive
 * @type {{show: MenuResp.show}}
 */
var MenuResp = {
  show: function () {
    document.getElementsByClassName("topnav")[0].classList.toggle("responsive");
  }
};
<nav>
  <ul class="topnav">
  <li><a href="#home">Home</a></li>
  <li><a href="#news">News</a></li>
  <li><a href="#contact">Contact</a></li>
  <li><a href="#about">About</a></li>
  <li class="icon">
    <a href="javascript:void(0);" onclick="MenuResp.show()">&#9776;</a>
  </li>
</ul>
</nav>

以上是关于html menu.html的主要内容,如果未能解决你的问题,请参考以下文章

html DL-menu.html

html responsive_menu.html

如何保持一个图像按钮处于活动状态,直到单击另一个

jQuery (IBM Worklight) 页面导航和后退按钮

django模板白页

框架复习