这篇文章将为大家详细讲解有关怎么用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实现响应式滑动菜单”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。