效果

出现

css部分

.content-wrapper{
-webkit-transition: -webkit-transform .3s ease-in-out, margin .3s ease-in-out;
-moz-transition: -moz-transform .3s ease-in-out, margin .3s ease-in-out;
-o-transition: -o-transform .3s ease-in-out, margin .3s ease-in-out;
transition: transform .3s ease-in-out, margin .3s ease-in-out;
margin-left: 230px;
z-index: 820
} @media (max-width:767px) {
.content-wrapper{
margin-left: 0
}
} @media (min-width:768px) {
.sidebar-collapse .content-wrapper {
margin-left: 0
}
} @media (max-width:767px) {
.sidebar-open .content-wrapper{
-webkit-transform: translate(147px, 0);
-ms-transform: translate(147px, 0);
-o-transform: translate(147px, 0);
transform: translate(147px, 0)
}
} .content-wrapper{
min-height: 100%;
background-color: #ecf0f5;
z-index: 800
} /* 关键处 */
.main-sidebar{
position: absolute;
top: 60px;
padding-top: 0px;
min-height: 100%;
width: 145px;
z-index:;
-webkit-transition: -webkit-transform .3s ease-in-out, width .3s ease-in-out;
-moz-transition: -moz-transform .3s ease-in-out, width .3s ease-in-out;
-o-transition: -o-transform .3s ease-in-out, width .3s ease-in-out;
transition: transform .3s ease-in-out, width .3s ease-in-out
}
/* 关键处 */
@media (max-width:767px) {
.main-sidebar{
-webkit-transform: translate(-150px, 0);
-ms-transform: translate(-150px, 0);
-o-transform: translate(-150px, 0);
transform: translate(-150px, 0)
}
} @media (min-width:768px) {
.sidebar-collapse .main-sidebar{
-webkit-transform: translate(-150px, 0);
-ms-transform: translate(-150px, 0);
-o-transform: translate(-150px, 0);
transform: translate(-150px, 0)
}
} @media (max-width:767px) {
.sidebar-open .main-sidebar{
-webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
-o-transform: translate(0, 0);
transform: translate(0, 0)
}
}

html部分

<body>
<div class="top">
<span class="sidebar-toggle glyphicon glyphicon-th-list category_list" aria-hidden="true"></span>
</div>
<!--中间-->
<div id="" class="mid">
<!--中间左边-->
<div id="" class="left main-sidebar">
main-sidebar
</div>
<!--中间右边-->
<div id="" class="clear">
</div>
<div id="" class="right content-wrapper">
content-wrapper
</div>
</div>
</body>

jQuery部分

<script type="text/javascript">

    //Enable sidebar toggle
$(document).ready(function() {
$('.sidebar-toggle').click(function() {
if ($("body").hasClass('sidebar-collapse')) {
$("body").removeClass('sidebar-collapse');
} else {
$("body").addClass('sidebar-collapse');
} if ($("body").hasClass('sidebar-open')) {
$("body").removeClass('sidebar-open').removeClass('sidebar-collapse');
} else {
$("body").addClass('sidebar-open');
}
}); $(".content-wrapper").click(function() {
if ($("body").hasClass("sidebar-open")) {
$("body").removeClass('sidebar-open');
}
});
});
</script>

jquery+css实现菜单收缩效果并适应多种浏览器与移动平台的更多相关文章

  1. jQuery图片旋转展示收缩效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. jquery css 主菜单样式的跳转

    想要实现的效果事实上是挺常见的那种:网页的主菜单一開始有一种默认的样式(如A样式),当鼠标经过某一菜单项时.此菜单项会套用一种样式(如B样式),当鼠标点击某一菜单项时.当前菜单项会套用B样式,其余菜单 ...

  3. jQuery+CSS 简单代码实现遮罩层( 兼容主流浏览器 )

    /* ** jQuery版本:jQuery-1.8.3.min.js ** 浏览器:Chrome( v31.0.1650.63 m ),IE11,Firefox( v32.0.1 ),IETester ...

  4. css三级菜单效果

    一个简单实用的css三级菜单效果 <!doctype html> <html> <head> <meta charset="utf-8"& ...

  5. 实用js+css多级树形展开效果导航菜单

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. 推荐20款基于 jQuery & CSS 的文本效果插件

    jQuery 和 CSS 可以说是设计和开发行业的一次革命.这一切如此简单,快捷的一站式服务.jQuery 允许你在你的网页中添加一些真正令人惊叹的东西而不用付出很大的努力,要感谢那些优秀的 jQue ...

  7. jQuery Wheel 环形菜单插件5种效果演示

    很酷的菜单-jQuery Wheel 环形菜单插件5种效果演示在线预览 下载地址 实例代码 <div class="container"> <!-- Top Na ...

  8. js+css实现带缓冲效果右键弹出菜单

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. jquery 仿windows10菜单效果下载

    http://www.kuitao8.com/20150923/4079.shtml jquery 仿windows10菜单效果下载

随机推荐

  1. chrome播放语音时,在chrome 控制台中报 DOMException: The play() request was interrupted by a call to pause(). 的问题.

    $(document).ready(function () { var audioElement = $( '<audio>' + ' <source src="" ...

  2. iPhone手机GPS地图位置好帮手

    十一国庆黄金周近在眉睫,我先祝大家过一个愉快开心的国庆长假. 假期内,难免老友聚会吃饭聊天联络感情,年轻朋友相亲约会,一家人出门旅游.平时,我们聚会时,总有要来的人找不到聚会地点,需要反复打电话确认: ...

  3. 【.NET特供-第三季】ASP.NET MVC系列:MVC与三层图形对照(颠覆性理论)

           在[.NET特供-第三季]系列博客中的第一篇<ASP.NET MVC系列:MVC与三层图形对照>发表之后,引起了领导的注意.同一时候,开发小组内部在交流MVC和三层之间关系的 ...

  4. 【解决】hive动态添加partitions不能超过100的问题

    Author: kwu [解决]hive动态添加partitions不能超过100的问题,全量动态生成partitions超过100会出现例如以下异常: The maximum number of d ...

  5. Ambari安装

    给hadoop用户sudo权限 hadoop ALL=(ALL) NOPASSWD:ALL 建立SSH互信,参考Hadoop HA的搭建中的互信建立 建立相应的下载脚本down.sh nohup wg ...

  6. Python 的数据类型

    列表 #coding=utf-8 students=["小明","小华","小李","小娟","小云" ...

  7. C#关于使用枚举遇到的问题----Parse()方法使用注意

    声明了一个枚举 public enum ceshimeiju { 跃动,光子} ceshimeiju ce = Enum.Parse(typeof(ceshimeiju ), "跃动&quo ...

  8. hdu 2218

    题意: 切蛋糕问题 水题...... AC代码: #include <iostream> using namespace std; int main() { int a[6],i,n; c ...

  9. ADSL拨号连接

    dotras是一个提供远程访问服务的组件,使用它可以方便的 进行宽带拨号连接 由于不同的系统中dotras调用的底层api可能不同,所以使用时要根据不同的系统使用不同的dotras. dotras目前 ...

  10. iOS之使用QLPreviewController打开文件,处理txt文件出现乱码的情况

    iOS之使用QLPreviewController打开文件,处理txt文件出现乱码的情况 主要代码: - (id <QLPreviewItem>)previewController:(QL ...