Home  >  Article  >  Web Front-end  >  Using jquery to implement HTML5 responsive navigation menu tutorial_html5 tutorial skills

Using jquery to implement HTML5 responsive navigation menu tutorial_html5 tutorial skills

WBOY
WBOYOriginal
2016-05-16 15:48:161357browse

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>

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>

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.

Statement:
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