Home > Web Front-end > H5 Tutorial > body text

Using jquery to implement HTML5 responsive navigation menu tutorial_html5 tutorial skills

WBOY
Release: 2016-05-16 15:48:16
Original
1350 people have browsed it

Achieved through jquery html5, when the browser window is reduced or the mobile phone is accessed, the navigation menu becomes a button drop-down menu. Rendering:

Using jquery to implement HTML5 responsive navigation menu tutorial_html5 tutorial skills

HTML code:

<br><div class="msgheader">
<div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode103'));"><u>复制代码</u></span></div>代码如下:</div><div class="msgborder" id="phpcode103"><nav id="nav-wrap"><br> <ul id="nav">
<br>  <li><a href="#">Button</a></li>
<br>  <li><a href="#">Button</a></li>
<br> </ul>
<br></nav></div>
Copy after login

jQuery code:

The following jquery code will add

View the element through the browser and you can see that the code displayed in html is as follows:

<br><div class="msgheader">
<div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode105'));"><u>复制代码</u></span></div>代码如下:</div><div class="msgborder" id="phpcode105">
<br><nav id="nav-wrap"><br> <div id="menu-icon">Menu</div>
<br> <ul id="nav">
<br>  <li><a href="#">Button</a></li>
<br>  <li><a href="#">Button</a></li>
<br> </ul>
<br></nav>
</div>
Copy after login

CSS code:

In the css code, you must first set the attribute of #menu-icon to display:none;, then use the media query to judge and then change #menu-icon to display:block;. The following is the key CSS style code , determine the style when the browser width is less than 600px:

Using jquery to implement HTML5 responsive navigation menu tutorial_html5 tutorial skills

For the final effect, please see the first rendering in the article.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template