ハンバーガーメニュー
html
<body>
<div id="app">
<header class="header">
<div class="header_menu">
<div class="header_menu_line" @click="naviOpen" :class="{'is-active': active}">
<span></span>
<span></span>
<span></span>
</div>
</div>
</header>
<transition name="navi">
<nav class="navi" v-show="navi">
<ul class="navi_wrap">
<li><a href="#">AAA</a></li>
<li><a href="#">BBB</a></li>
<li><a href="#">CCC</a></li>
<li><a href="#">DDD</a></li>
<li><a href="#">EEE</a></li>
</ul>
</nav>
</transition>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
active: false,
navi: false,
},
methods: {
naviOpen: function() {
this.active = !this.active;
this.navi = !this.navi;
}
}
})
</script>
css
.header {
width: 100%;
background: #fff;
height: 60px;
}
.header_menu {
width: 60px;
height: 60px;
position: fixed;
top: 0;
right: 0;
}
.header_menu_line {
width: 36px;
height: 30px;
margin-top: 15px;
margin-left: auto;
margin-right: auto;
position: relative;
cursor: pointer;
}
.header_menu_line span {
width: 100%;
height: 2px;
background: #000;
display: block;
transition: .6s;
position: absolute;
}
.header_menu_line span:first-child {
top: 0;
}
.header_menu_line span:nth-child(2) {
top: 14px;
}
.header_menu_line span:last-child {
bottom: 0;
}
.header_menu_line.is-active span {
transition: .6s;
}
.header_menu_line.is-active span:first-child {
transform: rotate(45deg);
top: 50%;
}
.header_menu_line.is-active span:nth-child(2) {
opacity: 0;
}
.header_menu_line.is-active span:last-child {
transform: rotate(-45deg);
top: 50%;
}
.navi {
width: 100%;
/* height: 100vh;*/
display: flex;
justify-content: center;
align-items: center;
color: #fff;
}
.navi_wrap {
list-style-type: none;
text-align: center;
padding-left: 0;
background: #4b4b4b;
padding: 40px 0;
}
.navi_wrap li a {
text-decoration: none;
color: #fff;
display: block;
padding: 20px;
}
.navi-enter, .navi-leave-to {
opacity: 0;
}
.navi-enter-to, .navi-leave {
opacity: 1;
}
.navi-enter-active, .navi-leave-active {
transition: .6s;
}