移动端侧滑导航代码

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			html{font-size: 62.5%;}
			*{
				margin: 0;
				padding: 0;
			}
			body{
				font-size: 1.5rem;
				color: #333333;
				background: white;
				height: 100%;
			}
			html,body{
				height: 100%;
			}
			header,footer{
				position: fixed;
				left: 0;
				right: 0;
				text-align: center;
				height: 44px;
				line-height: 44px;
				z-index: 1;
				background: blue;
				color: white;
			}
			header{
				border-bottom: 2px black solid;
				top: 0;
			}
			footer{
				border-top: 2px black solid;
				bottom: 0;
				}
			.page-title{
				font-size: 1.8rem;
				font-weight: normal;
			}
			.btn-slide-bar{
				width: 44px;
				height: 44px;
				display: block;
				float: left;
				line-height: 2.8;
				cursor: pointer;/*鼠标变手*/
			}
			.btn-slide-bar::after{/*面包屑导航*/
				content: "";
				width: 20px;
				height: 2px;
				background: #999;
				display: inline-block; /*文字属性*/
				box-shadow:0 7px 0 #999,0 -7px 0 #999;
			}
			.parwer-page{
				position: absolute;
				top: 44px;
				right: 0;
				left: 0;
				overflow: hidden;
			}
			.slide-bar{
				position: absolute;
				top: -1px;
				bottom: -1px;
				background: #333333;
				width: 150px;
				left: 0;
				z-index: 2;
				transform: translateX(-150px);
				-moz-transform: translateX(-150px);
				-o-transform: translateX(-150px);
				-webkit-transform: translateX(-150px);
				-ms-transform: translateX(-150px);
				
				transition: all 0.2s ease-in-out;
				-moz-transition: all 0.2s ease-in-out;
				-o-transition: all 0.2s ease-in-out;
				-webkit-transition: all 0.2s ease-in-out;
				-ms-transition: all 0.2s ease-in-out;
			}
			.slide-bar li{
				list-style: none;
				height: 40px;
				text-align: center;
				line-height: 40px;
				color: white;
				border-bottom: 2px solid #000000;
			}
			body{
				transition: all 0.2s ease-in-out;
				-moz-transition: all 0.2s ease-in-out;
				-o-transition: all 0.2 ease-in-out;
				-webkit-transition: all 0.2s ease-in-out;
				-ms-transition: all 0.2s ease-in-out;
			}
			body.active{
				transform: translateX(150px);
				-moz-transform: translateX(150px);
				-o-transform: translateX(150px);
				-webkit-transform: translateX(150px);
				-ms-transform: translateX(150px);
				transition: all 0.2s ease-in-out;
				-moz-transition: all 0.2s ease-in-out;
				-o-transition: all 0.2s ease-in-out;
				-webkit-transition: all 0.2s ease-in-out;
				-ms-transition: all 0.2s ease-in-out;
			}
		</style>
	</head>

	<body>
		<header>
			<span class="btn-slide-bar">
				
			</span>
			<h1 class="page-title">
				首页
			</h1>
		</header>
		<section class="parwer-page">内容</section>
		<footer>底部</footer>
		<section class="slide-bar">
			<ul>
				<li>css</li>
				<li>js</li>
				<li>html</li>
				<li>node</li>
			</ul>
		</section>
		<script type="text/javascript">
			//将我们的dom树加载完毕以后执行 它不会去理会js ,css 图像 是否加载完毕
			 document.addEventListener("DOMContentLoaded",function(){
			 	 (function(){
			 	 	  var _btn = document.querySelector(".btn-slide-bar"),
			 	 	      _body = document.querySelector("body");
			 	 	      
			 	 	      _btn.onclick = function(){
			 	 	      	_body.classList.toggle("active")
			 	 	      }
			 	 })(window)
			 })
		</script>
	</body>

</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值