Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a responsive hamburger menu in AMP HTML

Tags:

amp-html

I'm trying to create an AMP HTML website (see https://www.ampproject.org) But i can't find anywhere how you are supposed to create a responsive hamburger menu ? Javascript is not allowed and there are no AMP Components available for it ?

like image 995
Erwin Beckers Avatar asked Dec 07 '15 14:12

Erwin Beckers


Video Answer


1 Answers

I have accomplished this with the use of a :target pseudoclass.

HTML

<nav id="slide-in-menu">
  ...nav menu content...
</nav>
<section class="content-section">
  <a href="#slide-in-menu">Hamburger Icon</a>
</section>

CSS

#slide-in-menu {
  transform: translateX(-100%);
  transition: transform .2s ease-in-out;
  ... additional required styles ...
}
#slide-in-menu:target {
  transform: translateX(0);
}
like image 107
somecallmejosh Avatar answered Oct 11 '22 15:10

somecallmejosh