Skip to content

Commit

Permalink
Merge pull request #46 from ggam/revamp-offcanvas
Browse files Browse the repository at this point in the history
Simplified Off Canvas example
  • Loading branch information
mdo committed Aug 15, 2013
2 parents 0a7b185 + 6e8ace4 commit 0bc2a69
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 102 deletions.
52 changes: 27 additions & 25 deletions offcanvas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,88 +9,90 @@
<title>Off Canvas Template for Bootstrap</title>

<!-- Bootstrap core CSS -->
<link href="../bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="offcanvas.css" rel="stylesheet">
</head>

<body>

<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar navbar-fixed-top navbar-inverse" role="navigation">
<div class="container">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">

<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

<a class="navbar-brand" href="#">Project name</a>
<div class="nav-collapse collapse">

<div class="nav-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div><!-- /.nav-collapse -->
</div><!-- /.container -->
</div><!-- /.navbar -->

<div class="container">

<div class="row row-offcanvas row-offcanvas-right">
<div class="col-lg-9">
<p class="pull-right hidden-lg">
<button type="button" class="btn btn-primary btn-offcanvas" data-toggle="offcanvas"><i class="glyphicon glyphicon-resize-horizontal"></i></button>
<div class="col-12 col-sm-9 col-lg-9">
<p class="pull-right visible-sm">
<button type="button" class="btn btn-primary btn-xs" data-toggle="offcanvas">Toggle nav</button>
</p>
<div class="jumbotron">
<h1>Hello, world!</h1>
<p>This is an example to show the potential of an offcanvas layout pattern in Bootstrap. Try some responsive-range viewport sizes to see it in action.</p>
</div>
<div class="row">
<div class="col-sm-6 col-lg-4">
<div class="col-6 col-sm-6 col-lg-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#">View details &raquo;</a></p>
</div><!--/span-->
<div class="col-sm-6 col-lg-4">
<div class="col-6 col-sm-6 col-lg-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#">View details &raquo;</a></p>
</div><!--/span-->
<div class="col-sm-6 col-lg-4">
<div class="col-6 col-sm-6 col-lg-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#">View details &raquo;</a></p>
</div><!--/span-->
<div class="col-sm-6 col-lg-4">
<div class="col-6 col-sm-6 col-lg-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#">View details &raquo;</a></p>
</div><!--/span-->
<div class="col-sm-6 col-lg-4">
<div class="col-6 col-sm-6 col-lg-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#">View details &raquo;</a></p>
</div><!--/span-->
<div class="col-sm-6 col-lg-4">
<div class="col-6 col-sm-6 col-lg-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#">View details &raquo;</a></p>
</div><!--/span-->
</div><!--/row-->
</div><!--/span-->
<nav class="col-lg-3 sidebar-offcanvas" id="sidebar" role="navigation">
<nav class="col-3 col-sm-3 col-lg-3 sidebar-offcanvas" id="sidebar" role="navigation">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Sidebar</li>
<ul class="nav">
<li>Sidebar</li>
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="nav-header">Sidebar</li>
<li>Sidebar</li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="nav-header">Sidebar</li>
<li>Sidebar</li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
Expand All @@ -101,14 +103,14 @@ <h2>Heading</h2>
<hr>

<footer>
<p>&copy; Company 2012</p>
<p>&copy; Company 2013</p>
</footer>

</div><!--/.container-->


<!-- jQuery and plugin -->
<script src="../assets/js/jquery.js"></script>
<script src="../bootstrap/js/bootstrap.min.js"></script>
<script src="offcanvas.js"></script>
</body>
</html>
</html>
102 changes: 25 additions & 77 deletions offcanvas/offcanvas.css
Original file line number Diff line number Diff line change
@@ -1,100 +1,48 @@
/*
* Style twaks
* --------------------------------------------------
*/
body {
padding-top: 80px;
padding-top: 70px;
}
footer {
padding-left: 15px;
padding-right: 15px;
}

/*
* Off canvas
* -------------------------------------------------- */

.row-offcanvas {
position: relative;
overflow: hidden;
-webkit-transition: all 0.25s ease-out;
-moz-transition: all 0.25s ease-out;
transition: all 0.25s ease-out;
}
.row-offcanvas.active {
overflow: visible;
}
.row-offcanvas-right .sidebar-offcanvas {
right: -210px; /* 60px * 3.5 = very small phones like 240x320 HTC Wildfire */
}
.row-offcanvas-left .sidebar-offcanvas {
left: -210px; /* 60px * 3.5 = very small phones like 240x320 HTC Wildfire */
}
.row-offcanvas-right.active {
right: 210px; /* 60px * 3.5 = very small phones like 240x320 HTC Wildfire */
}
.row-offcanvas-left.active {
left: 210px; /* 60px * 3.5 = very small phones like 240x320 HTC Wildfire */
}
.sidebar-offcanvas {
position: absolute;
top: 0;
}
* Off Canvas
* --------------------------------------------------
*/
@media screen and (max-width: 768px) {
.row-offcanvas {
position: relative;
overflow: hidden // Needed for Internet Explorer
-webkit-transition: all 0.25s ease-out;
-moz-transition: all 0.25s ease-out;
transition: all 0.25s ease-out;
}

@media screen and (max-width: 319px) {
/* This is here instead of being outside the media queries because when
* we exit "mobile land", the sidebar needs to be able to restore its
* originally authored ".col-lg-X" width. */
.row-offcanvas-right
.sidebar-offcanvas {
width: 210px; /* 60px * 3.5 = very small phones like 240x320 HTC Wildfire */
right: -58.333333333333336%; // 6 columns
}
}

@media screen and (min-width: 320px) and (max-width: 480px) {
.row-offcanvas-right .sidebar-offcanvas {
right: -270px; /* 60px * 4.5 = average iPhones and Android phones */
}
.row-offcanvas-left .sidebar-offcanvas {
left: -270px; /* 60px * 4.5 = average iPhones and Android phones */
}
.row-offcanvas-right.active {
right: 270px; /* 60px * 4.5 = average iPhones and Android phones */
}
.row-offcanvas-left.active {
left: 270px; /* 60px * 4.5 = average iPhones and Android phones */
}
.row-offcanvas-left
.sidebar-offcanvas {
width: 270px; /* 60px * 4.5 = average iPhones and Android phones */
left: -58.333333333333336%; // 6 columns
}
}

/* Landscape phone to tablets
* -------------------------- */
@media screen and (min-width: 481px) and (max-width: 767px) {
.row-offcanvas-right .sidebar-offcanvas {
right: -480px; /* 60px * 8 = Tablets and wider */
}
.row-offcanvas-left .sidebar-offcanvas {
left: -480px; /* 60px * 8 = Tablets and wider */
}
.row-offcanvas-right.active {
right: 480px; /* 60px * 8 = Tablets and wider */
right: 58.333333333333336%; // 6 columns
}

.row-offcanvas-left.active {
left: 480px; /* 60px * 8 = Tablets and wider */
}
.sidebar-offcanvas {
width: 480px; /* 60px * 8 = Tablets and wider */
left: 58.333333333333336%; // 6 columns
}
}

/* Tablets & above
* ---------------- */
@media screen and (min-width: 768px) {
.row-offcanvas {
position: static;
overflow: visible;
}
.sidebar-offcanvas {
position: static;
}
.btn-offcanvas {
display: none;
position: absolute;
width: 58.333333333333336%; // 6 columns
}
}

0 comments on commit 0bc2a69

Please sign in to comment.