Off-canvas
An off-canvas element appears on request on either side of the page and overlays or pushes away the main page content.
This can be used for navigation menus or other side panels that don’t need to be permanently visible.
To open an off-canvas element, call the offCanvas
jQuery extension function on the element to show as off-canvas. The function takes the options as its single argument. The options are optional and can alternatively be specified as data-opt
HTML attributes with the off-canvas HTML element. The following options are supported:
Option
Type
Description
Default
cancellable
Boolean
Indicates whether the user can close the off-canvas panel by clicking anywhere outside of it or pressing Esc .
true
edge
String
The side from which the off-canvas opens. Values: left, right
left
push
Number
Push the page content to the side when showing the off-canvas panel. 0 doesn’t push, 0.5 pushes half-way, 1 pushes the full panel width.
1
To open an off-canvas, use code like this:
$("#button1").click(function (event) {
$("#offCanvas1").offCanvas(options);
});
Here are a number of buttons that open the same off-canvas with different options.
Left panel, scrolling
Left panel, non-cancellable
Left panel, overlapping
Left panel, half-pushing
Right panel, overlapping
Right panel, half-pushing
Right panel, pushing
The off-canvas can be closed by code. This is done through a plugin extension function with a syntax similar to other jQuery functions.
$("#offCanvas1").offCanvas.close();
This space is intentionally left blank to demonstrate the page scroll lock while an off-canvas element is open.
Off-canvas 1
Fusce varius urna eget justo egestas, non convallis dolor condimentum. Donec eget augue ut ligula porttitor consequat. Donec eu magna sit amet risus auctor pharetra at at mi. Integer eget mattis ex, nec pharetra eros. Proin nec sem tempus, efficitur dui sit amet, aliquam urna. Phasellus tincidunt pellentesque molestie. In hendrerit scelerisque venenatis. Mauris commodo consequat nulla id hendrerit. Suspendisse a porta sapien. Sed id tortor eu nulla semper dictum. Curabitur at neque eleifend, dignissim odio ut, viverra turpis.
Donec eros neque, pharetra eget nisl finibus, sagittis mattis ligula. Sed a urna porttitor, egestas dui finibus, semper augue. Nulla vel eros massa. Quisque lacinia, orci ac viverra faucibus, libero urna posuere magna, eget sagittis lectus mi id felis. Etiam at magna sit amet urna euismod tincidunt sed nec lorem. Cras vitae lorem turpis. Quisque rhoncus, justo at mattis sagittis, nibh nisl tempor lectus, id commodo est sapien quis ante.
Quisque porta nibh justo, iaculis rhoncus mi malesuada nec. Sed commodo lacus vel neque pulvinar ultrices. Nulla finibus ut augue et pellentesque. Nulla sed tempus diam, in semper odio. Sed malesuada volutpat neque vitae dignissim. Praesent sit amet sem porttitor, convallis ex varius, vulputate diam. Vivamus a enim ac velit mattis cursus. Maecenas vestibulum tincidunt eros in vulputate. Pellentesque egestas massa mauris, ac vestibulum orci pulvinar ut. Donec porttitor congue odio, auctor efficitur magna lobortis ut. Sed efficitur sollicitudin leo in lacinia.
Pellentesque efficitur dapibus ante interdum elementum. Fusce scelerisque finibus lectus nec fermentum. Integer finibus, purus at maximus luctus, sapien nulla varius urna, id pulvinar ligula arcu nec tortor. Aenean vitae ornare arcu. Donec viverra id urna in iaculis. Nulla vestibulum sed mauris ut scelerisque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus sem tortor, hendrerit at velit non, accumsan ultricies felis. Aenean molestie ligula justo, nec efficitur lorem luctus ut. Quisque porta, nulla id placerat pretium, orci augue luctus dui, ac finibus urna diam vel lectus. Pellentesque ornare aliquet risus, eu feugiat tortor mollis ac. Integer tempus blandit dui sed rutrum.