https://github.com/christophery/pushy
Pushy is a responsive off-canvas navigation menu using CSS transforms & transitions.
https://github.com/christophery/pushy
css jquery menu navigation off-canvas-menu submenu
Last synced: about 1 month ago
JSON representation
Pushy is a responsive off-canvas navigation menu using CSS transforms & transitions.
- Host: GitHub
- URL: https://github.com/christophery/pushy
- Owner: christophery
- License: other
- Created: 2013-05-21T02:26:48.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-06-17T14:55:25.000Z (about 1 year ago)
- Last Synced: 2025-04-03T03:11:48.478Z (3 months ago)
- Topics: css, jquery, menu, navigation, off-canvas-menu, submenu
- Language: HTML
- Homepage: https://chrisyee.ca/pushy
- Size: 352 KB
- Stars: 1,488
- Watchers: 58
- Forks: 216
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Pushy
Pushy is a responsive off-canvas navigation menu using CSS transforms & transitions. This project was inspired by the off-canvas navigation menu seen on [Medium](https://medium.com/).
Pushy has been implemented on many sites, [check them out!](https://chrisyee.ca/pushy/#sites-using-pushy) Feel free to [contact me](https://chrisyee.ca/contact/) if you use Pushy in one of your websites.
Pushy has been featured on the [Treehouse Show](https://teamtreehouse.com/library/episode-118-page-transitions-designing-for-thumbs-concise?t=572), in a [book](https://www.google.ca/books/edition/Responsive_Mobile_Design/guZjBAAAQBAJ?hl=en&gbpv=1&dq=christopheryee.ca/pushy&pg=PA103&printsec=frontcover) and used in [Antarctica](https://www.antarctica.gov.au/)!
[View Demo](https://chrisyee.ca/pushy) | [Sites using Pushy](https://chrisyee.ca/pushy/#sites-using-pushy)
## Table of Contents
1. [Features](#features)
2. [Installation](#install)
3. [Development](#development)
4. [Options](#options)
5. [Sites using Pushy](#sites-using-pushy)## Features
- Uses CSS transforms & transitions
- No jQuery dependency (as of version 2.0)
- Smooth performance on mobile devices
- Menu/submenu closes when a link is selected
- Menu closes when the site overlay is selected
- Works with a keyboard (ESC closes the menu)
- Auto-collapsible submenus, nested to multiple levels
- Left or right menu position
- It's responsive!## Install
Download the [latest release](https://github.com/christophery/pushy/releases), this includes everything you need to get Pushy running on your site.
1. Add the stylesheet (`pushy.css`) in your head and the JS (`pushy.min.js`) file in your footer.
2. If you are using submenus, then you'll need to add the ```arrow.svg``` file into your `img` directory (optional).
3. Insert the following markup into your body.
```html
☰ Menu
```## CDN
Alternatively link directly to Pushy files on [cdnjs](https://cdnjs.com/libraries/pushy).
## NPM
If your are comfortable with command line, you can install Pushy as a [NPM package](https://www.npmjs.com/package/@cmyee/pushy):
```
npm install @cmyee/pushy
```## Development
Pushy CSS and JS are compiled and minified using Grunt. You'll need [Node](https://nodejs.org/en/) and [Grunt](https://gruntjs.com/) installed globally.**From the root directory run:**
```
$ npm install
$ grunt
```Now you can edit files in `/scss/` and `/js/`, which will be compiled to `/css/pushy.css` and `/js/pushy.min.js`.
## Options
### Menu Position
Use the ```.pushy-left``` or ```.pushy-right``` CSS class to specify the menu position.
```html
```
### data-focus
Use the `data-focus` attribute to give focus to a link when the menu is opened. Ideally the first link of the menu should be focused.
This data attribute accepts a CSS selector.
```html
```
### data-menu-btn-selector
Use the `data-menu-btn-selector` attribute to change the menu button CSS class for toggling the menu.
By default Pushy will use `.menu-btn` to toggle the menu.
This data attribute accepts a CSS selector.
**Note:** In v1.4.0 this attribute was renamed from `data-menu-btn-class` to `data-menu-btn-selector`
```html
Menu
```## Tips
- Use the ```.push``` CSS class on HTML elements outside of the ```.container```.
```html
This is a Heading
This is a subheading
```- If you are using SCSS, you can easily change the menu width by adjusting the ```$menu_width``` variable. The SCSS file [will need to be compiled](http://sass-lang.com/install) to CSS in order to see the change.
```css
$menu_width: 400px;```
- Not using SCSS? You'll have to update the multiple values (or do a find a replace!) in the ```pushy.css``` file.
```css
.pushy{
width: 400px; /* Changed the width to 400px */
}.pushy-left{
transform: translate3d(-400px,0,0); /* Updated the values */
/* Don't forget the vendor prefixes */
}.pushy-open-left .container,
.pushy-open-left .push {
transform: translate3d(400px, 0, 0); /* Updated the values */
}.pushy-right {
transform: translate3d(400px, 0, 0); /* Updated the values */
/* Don't forget the vendor prefixes */
}.pushy-open-right #.container,
.pushy-open-right .push {
transform: translate3d(-400px, 0, 0); /* Updated the values */
/* Don't forget the vendor prefixes */
}```
- If you want to prevent scrolling of your site when Pushy is open just add overflow-x: hidden and height: 100% to both the html & body tags.
```css
html, body{
overflow-x: hidden;
height: 100%;
-webkit-overflow-scrolling: touch;
}
```## Sites using Pushy
Pushy has been implemented on many sites in the wild, [check them out!](https://chrisyee.ca/pushy/#sites-using-pushy)
To add your site, [contact me](https://chrisyee.ca/contact/).