当前第2页 返回上一页
css实现布局和侧滑效果(侧滑的关键css3属性transform、transition)
代码不多,仅仅10行
1
2
3
4
5
6
7
8
9
10
* {margin:0;padding:0;}
#mobile-menu {position:fixed;top:0;left:0;width:220px;height:100%;background-color:#373737;z-index:9999;}
a:hover ,a:focus{text-decoration:none}
.mobile-nav ul li a {color:gray;display:block;padding:1em 5%; border-top:1px solid
#4f4f4f;border-bottom:1px solid #292929;transition:all 0.2s ease-out;cursor:pointer;#mobile-menu {position:fixed;top:0;left:0;width:220px;height:100%;background-color:#373737;z-index:9999;transition:all 0.3s ease-in;}}
.mobile-nav ul li a:hover {background-color:
#23A1F6;color: #ffffff;}
.show-nav {transform:translateX(0);}
.hide-nav {transform:translateX(-220px);}
.mobile-nav-taggle {height:35px;line-height:35px;width:35px;background-color:
#23A1F6;color:#ffffff;display:inline-block;text-align:center;cursor:pointer}
.nav.avbar-inverse{position:relative;}
.nav-btn {position:absolute;right:20px;top:20px;}
要值得注意的是css3的两个属性:
transform:旋转p,支持元素2D或3D旋转,属性值translateX(X)就是在X轴上移动Xpx的距离
而侧滑的动画效果是使用transition属性,设置属性的过渡动画的效果,语法
1
transition: property duration timing-
function
delay;
单击事件切换侧滑
1
2
3
4
5
6
7
8
9
10
11
12
13
$(
"#mobile-nav-taggle"
).click(
function
() {
var
mobileMenu = $(
"#mobile-menu"
);
if
(mobileMenu.hasClass(
"show-nav"
)) {
setTimeout(
function
() {
mobileMenu.addClass(
"hide-nav"
).removeClass(
"show-nav"
);
}, 100)
}
else
{
setTimeout(
function
(){
mobileMenu.addClass(
"show-nav"
).removeClass(
"hide-nav"
);
}, 100)
}
})
总结
不推荐用两个菜单导航栏,缺点很明显,为了实现效果而已,不要介意,其实用一个菜单导航栏也是可以实现,试试media 完全可以实现。
本文转载自:http://blog.csdn.net/kebi007/article/details/76038251
更多编程相关知识,请访问:编程视频!!
以上就是详解bootstrap自定义侧边导航栏的方法 的详细内容,更多文章请关注木庄网络博客 !
返回前面的内容
相关阅读 >>
rocketbootstrap 是什么
bootstrap 如何设置鼠标悬停提示
bootstrap 框架是什么意思
bootstrap 学习之表单格式与字体图标
bootstrap 怎么适配
使用bootstrap 框架的好处是什么
bootstrap 前端视图中如何实现页面内容模块化的隔离
什么是bootstrap 框架?
bootstrap 模态框加滚动条
一招搞定bootstrap 警告框
更多相关阅读请进入《bootstrap 》频道 >>
¥83.86元 人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » 详解bootstrap自定义侧边导航栏的方法