Last active
November 2, 2018 06:23
-
-
Save Bradley-D/b81c54d528db8fc9bc32e707488bb30e to your computer and use it in GitHub Desktop.
HTML: Menu for a hero area with animation
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
.hero-container-wrapper { | |
max-width: 400px; | |
width: 100%; | |
margin: 0 auto; | |
} | |
.hero-container-wrapper p { | |
text-align: left; | |
padding: 10px 20px; | |
margin-bottom: 0; | |
} | |
.hero-container-wrapper p a { | |
color: #595959; | |
display: block; | |
text-decoration: none; | |
width: 100%; | |
} | |
.hero-container-wrapper p.are-you-looking { | |
background: #fff; | |
-webkit-box-shadow: 6px 10px 2px -5px rgba(0, 0, 0, 0.25); | |
-moz-box-shadow: 6px 10px 2px -5px rgba(0, 0, 0, 0.25); | |
box-shadow: 6px 10px 2px -5px rgba(0, 0, 0, 0.25); | |
margin-bottom: 0; | |
padding-right: 3em; | |
border-color: inherit; | |
border-top-right-radius: 5px; | |
border-top-left-radius: 5px; | |
font-weight: bold; | |
} | |
.hero-container-wrapper p.are-you-looking:after { | |
content: "+"; | |
position: relative; | |
top: -5px; | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
float: right; | |
margin-right: -1.1em; | |
font-size: 40px; | |
line-height: 1; | |
-webkit-transition: -webkit-transform 0.5s; | |
transition: transform 0.5s; | |
} | |
.hero-container-wrapper.active p.are-you-looking:after { | |
-webkit-transform: rotate3d(0, 0, 1, 227deg); | |
transform: rotate3d(0, 0, 1, 227deg); | |
} | |
.hero-menu-wrapper { | |
background-color: #fff; | |
opacity: 0; | |
overflow: hidden; | |
padding: 0 20px 20px; | |
-webkit-transition: opacity 0.3s 0.4s, visibility 0s 0.7s; | |
transition: opacity 0.3s 0.4s, visibility 0s 0.7s; | |
width: 100%; | |
} | |
.hero-menu-wrapper.active { | |
opacity: 1; | |
-webkit-transition: opacity 0.3s; | |
transition: opacity 0.3s; | |
} | |
.hero-menu { | |
background: transparent; | |
list-style: none; | |
padding-left: 0; | |
} | |
.hero-menu-wrapper .hero-menu p { | |
padding-left: 0; | |
-webkit-transform: translate3d(110%, 0, 0); | |
transform: translate3d(110%, 0, 0); | |
-webkit-transition: opacity 0.3s, -webkit-transform 0.3s; | |
transition: opacity 0.3s, transform 0.3s; | |
} | |
.hero-menu-wrapper .hero-menu p:first-child { | |
border-top: 3px solid #000; | |
-webkit-transition-delay: 0.2s; | |
transition-delay: 0.2s; | |
} | |
.hero-menu-wrapper .hero-menu p:nth-child(2) { | |
-webkit-transition-delay: 0.15s; | |
transition-delay: 0.15s; | |
} | |
.hero-menu-wrapper .hero-menu p:nth-child(3) { | |
-webkit-transition-delay: 0.10s; | |
transition-delay: 0.10s; | |
} | |
.hero-menu-wrapper .hero-menu p:nth-child(4) { | |
-webkit-transition-delay: 0.05s; | |
transition-delay: 0.05s; | |
} | |
.hero-menu-wrapper .hero-menu p:nth-child(5) { | |
-webkit-transition-delay: 0.01s; | |
transition-delay: 0.01s; | |
} | |
.hero-menu-wrapper.active .hero-menu p { | |
-webkit-transform: translate3d(0, 0, 0); | |
transform: translate3d(0, 0, 0); | |
} | |
.hero-menu-wrapper .hero-menu p a:before { | |
content: ''; | |
position: absolute; | |
bottom: 1px; | |
left: 0; | |
height: 1px; | |
width: 100%; | |
background-color: #000; | |
} | |
.hero-menu-wrapper.active .hero-menu p:hover { | |
background: #595959; | |
padding-left: 20px; | |
} | |
.hero-menu-wrapper.active .hero-menu p:hover a { | |
color: #fff; | |
} | |
.hero-menu-wrapper .hero-menu p:hover a:before { | |
background-color: #fff; | |
} |
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="hero-container-wrapper"> | |
<p class="are-you-looking" tabindex="0">Are you looking for?</p> | |
<div class="hero-menu-wrapper"> | |
<div class="hero-menu"> | |
<p tabindex="0"><a href="https://www.destinationgoldcoast.com/where-to-stay">Accommodation</a></p> | |
<p tabindex="0"><a href="https://www.destinationgoldcoast.com/things-to-do">Things to Do</a></p> | |
<p tabindex="0"><a href="https://www.destinationgoldcoast.com/restaurants">Restaurants</a></p> | |
<p tabindex="0"><a href="https://www.destinationgoldcoast.com/tours-to-take">Tours</a></p> | |
<p tabindex="0"><a href="https://getbootstrap.com/docs/3.3/components/">Some option 5</a></p> | |
</div> | |
</div> | |
</div> |
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() { | |
jQuery(".are-you-looking").click(function() { | |
jQuery(".hero-container-wrapper, .hero-menu-wrapper").toggleClass("active"); | |
}); | |
// Helps with keyboard / accessibility | |
jQuery('p.are-you-looking').keydown(function(event) { | |
if (jQuery("p.are-you-looking").is(":focus") && event.key == "Enter") { | |
jQuery(".hero-container-wrapper, .hero-menu-wrapper").toggleClass("active"); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment