Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Off-canvas Navigation/Menu (Mobile) in Pure CSS using Tachyons? #10

Closed
nelsonic opened this issue Apr 30, 2017 · 4 comments
Closed

Off-canvas Navigation/Menu (Mobile) in Pure CSS using Tachyons? #10

nelsonic opened this issue Apr 30, 2017 · 4 comments

Comments

@nelsonic
Copy link
Member

nelsonic commented Apr 30, 2017

Can we build an "off-canvas" in pure CSS (without) an JS...?
Links/examples/code please if you have come across it! 👍

Edit:

Thanks to @Cleop for implementing this for the @dwyl site. #10 (comment)
We have split the code and simplified it so that anyone can learn from it!

GOTO: https://github.com/dwyl/learn-tachyons#responsive-navigation-menu

@iteles
Copy link
Member

iteles commented May 29, 2017

This is a pure CSS one that looks good, but I needs to be 'converted' to tachyons if we use it (looks mostly achievable without custom tachyons classes): https://isabelcastillo.com/pure-css-mobile-toggle-menu

@Cleop
Copy link
Member

Cleop commented Jun 14, 2017

This is what has been implemented on the dwyl-site redesign: https://github.com/dwyl/dwyl-site/pull/264/files#diff-b0638442d6af953ff33fca3d49113579L18

It is based on a similar approach to the link shared by @iteles. In summary you use a checkbox as your burger menu which alternates between hiding and revealing the menu when it is checked or unchecked (ie. when a user clicks on the burger to open/close the menu). The checkbox is hidden by using a <label> which is essentially a custom checkbox and in our case we use the burger bars as what we display to the user (to them it looks like a regular button not a toggling checkbox).

In order to display the menu, another class is required which uses the magic of the tilde ~ to alter the display of the menu elements by increasing their height so the hidden content can then be seen. The tilde looks for the sibling of the checkbox which contains the class .menu and changes on the active state of :checked (see the css excerpt below or checkout: https://stackoverflow.com/questions/10782054/what-does-the-tilde-squiggle-twiddle-css-selector-mean to learn more about how tildes work.)

Which looks like:

It was achieved using:

  • font awesome for the burger 'bars' shape with tachyons styling for coloring/sizing etc.
  • Tachyons absolute positioning to position this absolute top-1 right-1
  • Tachyons display options for different screen sizes dn-ns (display none on screens that are not small ie. don't show the burger menu unless you're using a mobile screen)
  • There were two custom classes created

As tachyons doesn't have min/max height values or this kind of transition specifically.

@johnyluyte
Copy link

Not pure CSS, but for anyone looking for a javascript way, here is an example: https://coralproject.net/

Right click to view its source and search for openNav.

It uses simple javascript to manipulate DOM class, and uses SVG for the burger button. Quite clean and straightforward.

@nelsonic nelsonic added this to To do in Nelson's List via automation Jan 30, 2020
nelsonic added a commit that referenced this issue Jan 31, 2020
@nelsonic nelsonic moved this from To do to Awaiting Feedback/Review in Nelson's List Jan 31, 2020
SimonLab added a commit that referenced this issue Feb 4, 2020
@nelsonic
Copy link
Member Author

nelsonic commented Feb 4, 2020

@nelsonic nelsonic closed this as completed Feb 4, 2020
Nelson's List automation moved this from Awaiting Feedback/Review to Done Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Nelson's List
  
Done
Development

No branches or pull requests

4 participants