Bootstrap Offcanvas - Super simple, easy to use off-canvas navigation menu for Bootstrap.
It uses Bootstrap classes and markup to create an off-canvas menu that not only looks good.
- nevşehir escort
- trabzon escort
- kastamonu escort
- gönen escort
- çorlu escort
- samsun escort
- balıkesir escort
- muğla escort
- rize escort
- erzincan escort
1. INCLUDE CSS AND JS FILES
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <link rel="stylesheet" href="../dist/css/bootstrap.offcanvas.min.css"/> <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="../dist/js/bootstrap.offcanvas.js"></script>
The below example is the exact same markup as from the Bootstrap docs. The only differences are the data-toggle, data-target attributes and offcanvas-toggle class.
<button type="button" class="navbar-toggle offcanvas-toggle" data-toggle="offcanvas" data-target="#js-bootstrap-offcanvas"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
Finally, the nav HTML should be as follows. The only things needed are:
- The class navbar-offcanvas
- The selector that is specified in the data-target of the toggle. Example below uses an ID. NOTE: This can also be any element as long as the classes and attributes are correct
<nav class="navbar navbar-default navbar-offcanvas" role="navigation" id="js-bootstrap-offcanvas"> ... </nav>
You can change the position of the off-canvas nav by adding the following class
There are four different events that are triggered on the nav element. These follow the same syntax as the Official Bootstrap JS plugins.
|show.bs.offcanvas||Fire before the offcanvas menu is shown|
|shown.bs.offcanvas||Fire after the offcanvas menu is shown|
|hide.bs.offcanvas||Fire before the offcanvas menu is hidden|
|hidden.bs.offcanvas||Fire after the offcanvas menu is hidden|
Its possible to customize to your needs by using SASS.
Want to include with your Bootstrap SASS? Copy across the files in src/sass.
The SASS files use a few variables. These are explained below.
$offcanvas-width: 250px !default; // The width of the offcanvas menu $offcanvas-animation-time: 0.15s !default; // Transition time to pull/hide menu $offcanvas-toggle-background: #f8f8f8 !default; // Background colour for toggle $offcanvas-toggle-bars-color: #000 !default; // Colour for icon bars in toggle
There is one media query and this uses the Bootstrap $screen-sm variable. If this isn't present, then the width of 768px is used for the breakpoint.