会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
犹记惊鸿照影(JS)
博客园
首页
新随笔
联系
订阅
管理
斗鱼的sidebar的实现简陋的demo
斗鱼的sidebar的实现简陋的demo
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8" /> <title></title> <style> .sidebar{ position:fixed; top:0; left:0; background:#f00; } .content{ width:200px; background:#666; height:200px; } .left-smcontent{ width:57px; display:none; background:#ccc; height:200px; } .small .content{ display:none;} .small .left-smcontent{ display:block;} .small .close{left:57px;} .close{ position:fixed; top:50%; left:200px; display:inline-block; width:30px; height:30px; background:red; } .main{margin-left:250px;} </style> </head> <body> <div id="sidebar" class="sidebar"> <div class="content"></div> <div class="left-smcontent"></div> <a href="javascript:;" id="close" class="close"></a> </div> <div class="main" id="main">2222222</div> <script> function $(id){ return document.getElementById(id) } function windowHight(){ return document.documentElement.clientHeight||document.body.clientHeight; } $("sidebar").style.height=windowHight()+"px"; window.onresize=function(){ $("sidebar").style.height=windowHight()+"px"; } $("close").onclick=function(){ if($("sidebar").className=="sidebar small"){ $("sidebar").className="sidebar"; $("main").style.marginLeft="250px" }else{ $("sidebar").className="sidebar small"; $("main").style.marginLeft="57px" } } </script></body> </html>
运行
//因为时间比较紧张,没有对源码进行详细的介绍,在周末的优化的时候都会一一的补上,并且对代码进行优化
2222222
posted @
2016-11-01 22:14
莺哥
阅读(
221
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告