javascript js + html + css - 汉堡菜单
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript js + html + css - 汉堡菜单相关的知识,希望对你有一定的参考价值。
<-- HTML -->
<div class="hamburger-menu">
<div class="bar"></div>
</div>
<-- END HTML -->
<-- SCSS -->
//Меню гамбургер -------//
$bar-width: 50px;
$bar-height: 5px;
$bar-spacing: 12.5px;
.hamburger-menu {
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
width: $bar-width;
height: $bar-height + $bar-spacing*2;
cursor: pointer;
}
.bar,
.bar:after,
.bar:before {
width: $bar-width;
height: $bar-height;
}
.bar {
position: relative;
transform: translateY($bar-spacing);
background: rgba(205, 205, 205, 1);
transition: all 0ms 300ms;
&.animate {
background: rgba(0, 0, 0, 0);
}
}
.bar:before {
content: "";
position: absolute;
left: 0;
bottom: $bar-spacing;
background: rgba(205, 205, 205, 1);
transition: bottom 300ms 300ms cubic-bezier(0.23, 1, 0.32, 1), transform 300ms cubic-bezier(0.23, 1, 0.32, 1);
}
.bar:after {
content: "";
position: absolute;
left: 0;
top: $bar-spacing;
background: rgba(205, 205, 205, 1);
transition: top 300ms 300ms cubic-bezier(0.23, 1, 0.32, 1), transform 300ms cubic-bezier(0.23, 1, 0.32, 1);
}
.bar.animate:after {
top: 0;
background-color: #ff0000;
transform: rotate(45deg);
transition: top 300ms cubic-bezier(0.23, 1, 0.32, 1), transform 300ms 300ms cubic-bezier(0.23, 1, 0.32, 1);;
}
.bar.animate:before {
bottom: 0;
background-color: #ff0000;
transform: rotate(-45deg);
transition: bottom 300ms cubic-bezier(0.23, 1, 0.32, 1), transform 300ms 300ms cubic-bezier(0.23, 1, 0.32, 1);;
}
//-------------------------//
<-- END SCSS -->
<-- JS -->
(function () {
$('.hamburger-menu').on('click', function() {
$('.bar').toggleClass('animate');
})
})();
<-- END JS -->
以上是关于javascript js + html + css - 汉堡菜单的主要内容,如果未能解决你的问题,请参考以下文章
Javascript
JS和CS互访后台前台代码调用JavaScript变量以及JavaScript调用代码变量
请教大师们,JavaScript怎么调用.cs文件方法啥的?
javascript基础dom操作html元素
winform WebBrowser控件中,cs后台代码执行动态生成的js
.net 用户控件ascx.cs注册js脚本代码无效果