Last active
May 18, 2022 17:40
-
-
Save miracle777/20dbc0bcf366dd01b5fb4be10e17babe to your computer and use it in GitHub Desktop.
左から+通常
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="hamburger"> | |
<span></span> | |
<span></span> | |
<span></span> | |
</div> | |
<nav class="globalMenuSp"> | |
<ul> | |
<li><a href="#">Menu1</a></li> | |
<li><a href="#">Menu2</a></li> | |
<li><a href="#">Menu3</a></li> | |
<li><a href="#">Menu4</a></li> | |
<li><a href="#">Menu5</a></li> | |
</ul> | |
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('.hamburger').click(function() { | |
$(this).toggleClass('active'); | |
if ($(this).hasClass('active')) { | |
$('.globalMenuSp').addClass('active'); | |
} else { | |
$('.globalMenuSp').removeClass('active'); | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ハンバーガーボタン */ | |
.hamburger { | |
display : block; | |
position: fixed; | |
z-index : 3; | |
left : 13px; | |
top : 12px; | |
width : 42px; | |
height: 42px; | |
cursor: pointer; | |
text-align: center; | |
} | |
.hamburger span { | |
display : block; | |
position: absolute; | |
width : 30px; | |
height : 2px ; | |
left : 6px; | |
background : #555; | |
-webkit-transition: 0.3s ease-in-out; | |
-moz-transition : 0.3s ease-in-out; | |
transition : 0.3s ease-in-out; | |
} | |
.hamburger span:nth-child(1) { | |
top: 10px; | |
} | |
.hamburger span:nth-child(2) { | |
top: 20px; | |
} | |
.hamburger span:nth-child(3) { | |
top: 30px; | |
} | |
.hamburger.active span:nth-child(1) { | |
top : 16px; | |
left: 6px; | |
-webkit-transform: rotate(315deg); | |
-moz-transform : rotate(315deg); | |
transform : rotate(315deg); | |
} | |
.hamburger.active span:nth-child(2), | |
.hamburger.active span:nth-child(3) { | |
top: 16px; | |
-webkit-transform: rotate(-315deg); | |
-moz-transform : rotate(-315deg); | |
transform : rotate(-315deg); | |
} | |
nav.globalMenuSp { | |
position: fixed; | |
z-index : 2; | |
top : 0; | |
left : 0; | |
color: #000; | |
background: #fff; | |
text-align: center; | |
transform: translateX(-100%); | |
transition: all 0.6s; | |
width: 100%; | |
} | |
nav.globalMenuSp ul { | |
background: #ccc; | |
margin: 0 auto; | |
padding: 0; | |
width: 100%; | |
} | |
nav.globalMenuSp ul li { | |
list-style-type: none; | |
padding: 0; | |
width: 100%; | |
border-bottom: 1px solid #fff; | |
} | |
nav.globalMenuSp ul li:last-child { | |
padding-bottom: 0; | |
border-bottom: none; | |
} | |
nav.globalMenuSp ul li:hover{ | |
background :#ddd; | |
} | |
nav.globalMenuSp ul li a { | |
display: block; | |
color: #000; | |
padding: 1.4em 0; | |
text-decoration :none; | |
} | |
/* このクラスを、jQueryで付与・削除する */ | |
nav.globalMenuSp.active { | |
transform: translateX(0%); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment