web_qianduan
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>js+css3电脑手机端自适应响应式导航菜单代码</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<nav>
<div id="menu_button_wrapper">
<div id="menu_button">
Menu
<div id="hamburger">
<span></span>
<span></span>
<span></span>
</div>
</div>
<div class="clearfix"></div>
</div>
<ul id="menu_list">
<li class="current_page"><a href="#">Home</a></li>
<li><a href="#">Audio</a></li>
<li><a href="#">Video</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Contacts</a></li>
</ul>
</nav>
<script type="text/javascript">
function addListener(element, type, callback) {
if (element.addEventListener) {
element.addEventListener(type, callback);
} else if (element.attachEvent) {
element.attachEvent('on' + type, callback);
}
}
addListener(document, 'DOMContentLoaded', function () {
var mq = window.matchMedia("(max-width: 760px)");
if (mq.matches) {
document.getElementById("menu_list").classList.add("hidden");
}
addListener(document.getElementById("menu_button"), 'click', function () {
document.getElementById("menu_list").classList.toggle("hidden");
});
addListener(window, 'resize', function () {
var width = window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
if (width > 760) {
document.getElementById("menu_list").classList.remove("hidden");
} else {
document.getElementById("menu_list").classList.add("hidden");
}
});
});
</script>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
<p>适用浏览器:360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗. 不支持IE8及以下浏览器。</p>
<p>来源:<a href="http://www.lanrenzhijia.com/" target="_blank">懒人素材</a></p>
</div>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
css
body {
margin: 0;
}
.clearfix {
clear: both;
}
nav {
font-family: Helvetica;
text-align: right;
text-transform: uppercase;
background-color: #222;
}
nav ul {
width: 90%;
max-width: 1024px;
margin: 0 auto;
list-style-type: none;
}
nav ul li {
display: inline-block;
}
nav ul li a {
color: #9d9d9d;
font-weight: bold;
text-decoration: none;
display: inline-block;
padding: 1em;
box-sizing: border-box;
}
nav ul li a:hover {
color: white;
}
.current_page {
background-color: black;
}
.current_page a {
color: white;
}
#menu_button_wrapper{
display: none;
}
.hidden {
display: none;
}
/* Responsive for smaller screens */
@media (max-width: 760px) {
#menu_button_wrapper{
display: block;
padding: 1em;
color: #9d9d9d;
border-bottom: 1px solid #101010;
-webkit-box-shadow: 0 1px 0 rgba(255,255,255,.1);
box-shadow: 0 1px 0 rgba(255,255,255,.1);
margin-bottom: .5em;
}
#menu_button {
box-sizing: border-box;
float: right;
padding: .5em 1em;
border: 1px solid #333;
border-radius: 5px;
color: white;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#menu_button:hover {
cursor: pointer;
background-color: #333;
}
#hamburger {
float: right;
padding-top: .15em;
}
#menu_button span{
display: block;
background-color: #fff;
width: 1.2em;
height: .15em;
border-radius: 1px;
margin-bottom: .2em;
}
nav ul {
width: 100%;
margin: 0 auto;
padding: 0;
box-sizing: border-box;
}
nav ul li {
display: block;
}
nav ul li a {
width: 100%;
}
}
web_qianduan的更多相关文章
- 只需两步删除 node_modules
peng@PENG-PC /E/_My_File_____/home/learn/web_qianduan/mithril-demo/demo2/mithril -demo $ npm install ...
随机推荐
- jQuery实现一个淡入淡出下拉菜单 非常简易
前段时间我一直在向大家推荐CSS3和HTML5的东西,尽管看上去很炫,但也有不少网友抱怨兼容性问题,所以今天开始我也会陆续向大家介绍一些兼容性较好的jQuery插件.今天先分享一款利用jQuery实现 ...
- PHP多文件上传操作
在前一篇文章里讲到了关于PHP文件上传原理和简单操作举例是单文件上传. http://www.cnblogs.com/lichenwei/p/3879566.html 其实多文件上传和单文件上传大同小 ...
- 清除 Xcode 项目缓存
运行错误.编译错误.发布错误可尝试清除 Xcode 缓存:清除 Xcode 缓存也能减少占用磁盘空间. (1)前往文件夹(control+shift+G),删除里面的文件: /Users/用户名/Li ...
- 获取 SharpSvn 执行 svn 操作的实时日志
1 获取 SharpSvn 操作日志的方式 之前一篇随笔(使用 SharpSvn 执行 svn 操作)讲到可以通过声称一个绑定到一个 SvnClient 对象的 SvnClientReport 对象. ...
- UNIX环境编程学习笔记(10)——文件I/O之硬链接和符号链接
lienhua342014-09-15 1 文件系统数据结构 UNIX 文件系统通过 i 节点来存储文件的信息.如图 1 所示为一个磁盘柱面上的 i 节点和数据块示意图.其中 i 节点是一个固定长度的 ...
- WebGL 进入三维世界
1.观察目标点和上方向 为了确定观察者的状态,你需要获取两项信息:视点,即观察者的位置:观察目标点(look-at point),即被观察目标所在的点,它可以用来确定视线.此外,因为我们需要把观察到的 ...
- ThreadLocal用法
使用ThreadLocal能实现线程级别的变量定义,同一个类的私有静态变量,在不同的线程中值可以不同. 1.学习文章:http://blog.csdn.net/qjyong/article/detai ...
- [原]unity3D 移动平台崩溃信息收集
http://m.blog.csdn.net/blog/catandrat111/8534287http://m.blog.csdn.net/blog/catandrat111/8534287
- [mysql] Incorrect string value: '\xE4\xBC\x9A\xE5\x91\x98' for column 'name' at row 1
数据库字符集错误, 修改为UTF8/utf8mb4字符集即可.
- [OpenCV] IplImage and Operation
IplImage 一.资源 In this chapter, APIs will make U crazy. Good luck! Next, Review Linear Algebra. Ref: ...