[英]bootstrap menu icon change to x close
I would like,when clicking on the menu icon change to an X shape with animation and when clicking on X shape it change to menu icon. 我想单击动画时将菜单图标更改为X形状,而单击X形状时将其更改为菜单图标。 menu style in my site is exactly like evernote.com but menu icon must change to X .
我网站上的菜单样式与evernote.com完全一样,但是菜单图标必须更改为X。 I don't know how can I write this changing shape.can any one give me idea or guide me with this problem.
我不知道如何写出这种变化的形状。任何人都可以给我想法或指导我解决这个问题。 I'm new in bootstrap and js .
我是bootstrap和js的新手。 I uploaded my site here
我在这里上传了我的网站
HTML HTML
<div class="col-xs-6">
<a class="bazar" href="">دانلود اپلیکیشن </a>
<button type="button" class="navbar-toggle" >
<span class="icon-bar top-m"></span>
<span class="icon-bar mid-m"></span>
<span class="icon-bar bottom-m"></span>
</button>
<div class="menu">
<span class="btnClose">×</span>
<ul>
<li><a href="index.html">صفحه اصلی</a></li>
<li><a href="question.html">سوالات متداول</a></li>
<li><a href="job.html">فرصت های شغلی</a></li>
<li><a href="aboutus.html">درباره ما</a></li>
</ul>
</div>
css CSS
.icon-bar{
transition: 0.6s ease;
transition-timing-function: cubic-bezier(.75, 0, .29, 1.01);
}
.top-animate {
background: #fff !important;
top: 13px !important;
-webkit-transform: rotate(45deg);
/* Chrome, Safari, Opera */
transform: rotate(45deg);
}
.mid-animate {
opacity: 0;
}
.bottom-animate {
background: #fff !important;
top: 13px !important;
-webkit-transform: rotate(-225deg);
/* Chrome, Safari, Opera */
transform: rotate(-225deg);
}
.bazar-green, .bazar {
color: #fff;
display: block;
font-size: 20px;
position: absolute;
right: 80px;
top: 5px;
line-height: 43px;
background: url(image/bazarlogo.png) no-repeat left center;
padding-left: 80px;
z-index: 401;
}
.navbar-toggle {
display: block;
position: absolute;
right: 0px;
top: 0px;
}
.navbar-toggle{
float: right;
padding: 9px 10px;
margin-top: 8px;
margin-right: 15px;
margin-bottom: 8px;
background-color: transparent;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.navbar-toggle .icon-bar {
background-color: #fff;
}
.navbar-toggle .icon-bar {
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
}
.menu {
width: 300px;
position: absolute;
z-index: 400;
background: rgba(0,0,0,0.7);
padding: 10px 30px;
text-align: right;
color: #fff;
font-size: 17px;
transition: all 1s;
right: -316px;
}
.btnClose {
color: #fff;
font-size: 30px;
cursor: pointer;
z-index: 500;
}
js JS
$('.navbar-toggle').click(function() {
$('.top-m').addClass('top-animate');
$('.mid-m').addClass('mid-animate');
$('.bottom-m').addClass('bottom-animate');
$('.menu').addClass('opened');
var height = $( window ).height();
$('.menu').css('height',height);
});
$('.btnClose').click(function() {
$('.menu').removeClass('opened');
$('.navbar-toggle').fadeIn();
});
Add extra class to span as below 添加额外的班级如下
<span class="icon-bar first"></span>
<span class="icon-bar middle"></span>
<span class="icon-bar final"></span>
Then in jQuery hide center span and rotate first span to 45deg using 然后在jQuery中隐藏中心跨度,并使用将第一个跨度旋转到45deg
transform: rotate(45deg);
and rotate final span to 125deg using 并使用将最终跨度旋转到125deg
transform: rotate(125deg);
and you have to adjust top properly 而且你必须适当调整顶部
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.