小编给大家分享一下如何使用css3实现响应式滑动菜单,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
<!DOCTYPEhtml>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge,chrome=1">
<metaname="viewport"content="width=device-width,initial-scale=1.0">
<title>CSS3滑动动画菜单DEMO演示</title>
<linkrel="stylesheet"type="text/css"href="css/default.css"/>
<linkrel="stylesheet"type="text/css"href="css/component.css"/>
<scriptsrc="js/modernizr.custom.js"></script>
</head>
<body>
<div>
<header>
<h2>CSS3响应式滑动菜单</h2>
</header>
<divclass="mainclearfix">
<navid="menu">
<ul>
<li>
<ahref="#">
<span>
<iaria-hidden="true"></i>
</span>
<span>Home</span>
</a>
</li>
<li>
<ahref="#">
<span>
<iaria-hidden="true"></i>
</span>
<span>Services</span>
</a>
</li>
<li>
<ahref="#">
<span>
<iaria-hidden="true"></i>
</span>
<span>Portfolio</span>
</a>
</li>
<li>
<ahref="#">
<span>
<iaria-hidden="true"></i>
</span>
<span>Blog</span>
</a>
</li>
<li>
<ahref="#">
<span>
<iaria-hidden="true"></i>
</span>
<span>Theteam</span>
</a>
</li>
<li>
<ahref="#">
<span>
<iaria-hidden="true"></i>
</span>
<span>mail</span>
</a>
</li>
</ul>
</nav>
<divstyle="text-align:center;clear:both"><br>
<scriptsrc="/gg_bd_ad_720x90.js"type="text/javascript"></script><scriptsrc="/follow.js"type="text/javascript"></script></div>
</div>
</div><!--/container-->
<script>
varchangeClass=function(r,className1,className2){
varregex=newRegExp("(?:^|\\s+)"+className1+"(?:\\s+|$)");
if(regex.test(r.className)){
r.className=r.className.replace(regex,''+className2+'');
}
else{
r.className=r.className.replace(newRegExp("(?:^|\\s+)"+className2+"(?:\\s+|$)"),''+className1+'');
}
returnr.className;
};
varmenuElements=document.getElementById('menu');
menuElements.insertAdjacentHTML('afterBegin','<buttontype="button"id="menutoggle"aria-hidden="true"><iaria-hidden="true"></i>Menu</button>');
document.getElementById('menutoggle').onclick=function(){
changeClass(this,'navtoogleactive','navtoogle');
}
</script>
</body>
</html>
以上是“如何使用css3实现响应式滑动菜单”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程网行业资讯频道!