**你好,我的菜單anomation不起作用,不知道爲什麼。它應該像這樣工作:當你點擊菜單圖標時,圖標從漢堡變成了十字。我的僞元素動畫不起作用
我的HTML是這樣的: **
<body>
<div class="menu">
<div class="line"></div>
</div>
<script>$('.menu').click(function(){
$this = $(this);
if ($this.hasClass('active')) {
$this.removeClass('active');
}
else {
$this.addClass('active');
}
});</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</body>
我的CSS是這樣的:
.menu {
position: absolute;
height: 40px;
width: 40px;
cursor: pointer;
top: 3%;
left: 95%;
z-index: 999;
}
.line {
height: 5px;
width: 40px;
background: red;
position: absolute;
top: 50%;
transition: all 250ms linear;
}
.line:after, .line:before {
content: ' ';
height: 5px;
width: 40px;
background: red;
position: absolute;
transition: all 250ms linear;
}
.line:before {
top: -10px;
}
.line:after {
bottom: -10px;
}
.menu.active .line {
background: transparent;
}
.menu.active .line:before {
background: red;
transform: rotate(-405deg);
top: 0px;
}
.menu.active .line:after {
background: red;
transform: rotate(405deg);
bottom: 0px;
}
好的應用程序應該做什麼。你能否詳細說明你的意思是「不工作」? – Christophe 2015-02-08 12:28:08