Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Otto <otto@github.com>2013-08-13 08:23:28 +0400
committerMark Otto <otto@github.com>2013-08-13 08:23:28 +0400
commit8bb7def26cac4d3166fbf2cc98f16c4151794676 (patch)
tree7021e3eb046cd0e1786f31ce9cb1dea3478097f4 /less/navbar.less
parenteac61de138278aa1c0d70dfed7a9515c714b6ad9 (diff)
Navbar refactor
* Now responsive by default (fits better with mobile-first approach) * Requires `.nav-header` to group `.navbar-brand` and `.navbar-toggle` for proper mobile display. * Changed `.nav-collapse` to `.navbar-collapse` * Simplified examples in docs
Diffstat (limited to 'less/navbar.less')
-rw-r--r--less/navbar.less288
1 files changed, 195 insertions, 93 deletions
diff --git a/less/navbar.less b/less/navbar.less
index 1549220c95..99bc4858c8 100644
--- a/less/navbar.less
+++ b/less/navbar.less
@@ -2,69 +2,88 @@
// Navbars
// --------------------------------------------------
+
// Wrapper and base class
+//
+// Provide a static navbar from which we expand to create full-width, fixed, and
+// other navbar variations.
+
.navbar {
position: relative;
min-height: @navbar-height; // Ensure a navbar always shows (e.g., without a .navbar-brand in collapsed mode)
margin-bottom: @navbar-margin-bottom;
- padding-left: @navbar-padding-horizontal;
- padding-right: @navbar-padding-horizontal;
background-color: @navbar-bg;
- border-radius: @navbar-border-radius;
// Prevent floats from breaking the navbar
.clearfix();
+
+ @media (min-width: @grid-float-breakpoint) {
+ border-radius: @navbar-border-radius;
+ }
}
-// Navbar nav links
-// -------------------------
-.navbar-nav {
- > li > a {
- padding-top: ((@navbar-height - @line-height-computed) / 2);
- padding-bottom: ((@navbar-height - @line-height-computed) / 2);
- color: @navbar-link-color;
- line-height: @line-height-computed;
- border-radius: @border-radius-base;
- &:hover,
- &:focus {
- color: @navbar-link-hover-color;
- background-color: @navbar-link-hover-bg;
- }
- }
- > .active > a {
- &,
- &:hover,
- &:focus {
- color: @navbar-link-active-color;
- background-color: @navbar-link-active-bg;
- }
- }
- > .disabled > a {
- &,
- &:hover,
- &:focus {
- color: @navbar-link-disabled-color;
- background-color: @navbar-link-disabled-bg;
- }
- }
+// Navbar heading
+//
+// Groups `.navbar-brand` and `.navbar-toggle` into a single component for easy
+// styling of responsive aspects.
- // Right aligned contents
- // Make them full width first so that they align properly on mobile
- &.pull-right {
- width: 100%;
+.navbar-header {
+ padding-left: @navbar-padding-horizontal;
+ padding-right: @navbar-padding-horizontal;
+ .clearfix();
+
+ @media (min-width: @grid-float-breakpoint) {
+ float: left;
}
}
+// Navbar collapse (body)
+//
+// Group your navbar content into this for easy collapsing and expanding across
+// various device sizes. By default, this content is collapsed when <768px, but
+// will expand past that for a horizontal display.
+//
+// To start (on mobile devices) the navbar links, forms, and buttons are stacked
+// vertically and include a `max-height` to overflow in case you have too much
+// content for the user's viewport.
+
+.navbar-collapse {
+ padding-top: 5px;
+ padding-bottom: 5px;
+ border-top: 1px solid darken(@navbar-bg, 7%);
+ box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
+ // Clear floated elements and prevent collapsing of padding
+ .clearfix();
+
+ // This is not automatically added to the `.navbar-fixed-top` because it causes
+ // z-index bugs in iOS7 (possibly earlier).
+ max-height: 360px;
+ overflow-x: visible;
+ overflow-y: scroll;
+ -webkit-overflow-scrolling: touch;
+
+ @media (min-width: @grid-float-breakpoint) {
+ width: auto;
+ padding-top: 0;
+ padding-bottom: 0;
+ border-top: 0;
+ }
+}
+
//
// Navbar alignment options
-// --------------------------------------------------
+//
+// Display the navbar across the entirity of the page or fixed it to the top or
+// bottom of the page.
-// Static navbar
+// Static top (unfixed, but 100% wide) navbar
.navbar-static-top {
- border-radius: 0;
+ @media (min-width: @grid-float-breakpoint) {
+ border-radius: 0;
+ }
}
// Fix the top/bottom navbars when screen real estate supports it
@@ -74,7 +93,11 @@
right: 0;
left: 0;
z-index: @zindex-navbar-fixed;
- border-radius: 0;
+
+ // Undo the rounded corners
+ @media (min-width: @grid-float-breakpoint) {
+ border-radius: 0;
+ }
}
.navbar-fixed-top {
top: 0;
@@ -84,51 +107,12 @@
margin-bottom: 0; // override .navbar defaults
}
-.nav-collapse {
- // Prevent overlap of `.navbar-brand` and `.navbar-toggle`
- clear: both;
- // Space out collapsed contents within the mobile navbar
- padding-bottom: @navbar-padding-vertical;
- // Clear floated elements and prevent collapsing of padding
- .clearfix();
-
- // When there is no `.navbar-brand` present (which normally sits between the
- // navbar brand and toggle), prevent the nav from overlapping the toggle.
- .navbar-toggle + & {
- width: 100%;
- margin-top: @navbar-height;
- }
-}
-
-
-// Scrollable navbar navigation
-//
-// Sometimes you might have too many links in your fixed navbar and you need to
-// maintain access to all that content. To help, add `.nav-collapse-scrollable`
-// to your `.nav-collapse` to prevent the the content from flowing past the max-
-// height of your browser.
-//
-// This is not automatically added to the `.navbar-fixed-top` because it causes
-// z-index bugs in iOS7 (possibly earlier).
-
-@media (max-width: @screen-small) {
- .nav-collapse-scrollable {
- margin-bottom: @navbar-padding-vertical;
- max-height: 360px;
- overflow-y: scroll;
- -webkit-overflow-scrolling: touch;
- }
-}
-
-
-//
-// Navbar optional components
-// --------------------------------------------------
// Brand/project name
+
.navbar-brand {
float: left;
- margin-right: 15px;
+ margin-right: (@navbar-padding-horizontal / 2);
padding-top: @navbar-padding-vertical;
padding-bottom: @navbar-padding-vertical;
font-size: @font-size-large;
@@ -142,13 +126,17 @@
}
}
-// Collapsible navbar toggle
+
+// Navbar toggle
+//
+// Custom button for toggling the `.navbar-collapse`, powered by the collapse
+// JavaScript plugin.
+
.navbar-toggle {
position: relative;
float: right;
padding: 9px 10px;
.navbar-vertical-align(34px);
- margin-right: -10px;
background-color: transparent;
border: 1px solid @navbar-toggle-border-color;
border-radius: @border-radius-base;
@@ -171,12 +159,126 @@
}
}
+
+// Navbar nav links
+//
+// Builds on top of the `.nav` components with it's own modifier class to make
+// the nav the full height of the horizontal nav (above 768px).
+
+.navbar-nav {
+ > li > a {
+ padding-top: 10px;
+ padding-bottom: 10px;
+ color: @navbar-link-color;
+ line-height: @line-height-computed;
+ &:hover,
+ &:focus {
+ color: @navbar-link-hover-color;
+ background-color: @navbar-link-hover-bg;
+ }
+ }
+ > .active > a {
+ &,
+ &:hover,
+ &:focus {
+ color: @navbar-link-active-color;
+ background-color: @navbar-link-active-bg;
+ }
+ }
+ > .disabled > a {
+ &,
+ &:hover,
+ &:focus {
+ color: @navbar-link-disabled-color;
+ background-color: @navbar-link-disabled-bg;
+ }
+ }
+
+ // Right aligned contents
+ // Make them full width first so that they align properly on mobile
+ &.pull-right {
+ width: 100%;
+ }
+
+ @media (max-width: @screen-phone-max) {
+ // Dropdowns get custom display
+ .open .dropdown-menu {
+ position: static;
+ float: none;
+ width: auto;
+ margin-top: 0;
+ background-color: transparent;
+ border: 0;
+ box-shadow: none;
+ > li > a,
+ .dropdown-header {
+ padding: 5px 15px 5px 25px;
+ }
+ > li > a {
+ color: @navbar-link-color;
+ line-height: @line-height-computed;
+ &:hover,
+ &:focus {
+ color: @navbar-link-hover-color;
+ background-color: @navbar-link-hover-bg;
+ background-image: none;
+ }
+ }
+ > .active > a {
+ &,
+ &:hover,
+ &:focus {
+ color: @navbar-link-active-color;
+ background-color: @navbar-link-active-bg;
+ }
+ }
+ > .disabled > a {
+ &,
+ &:hover,
+ &:focus {
+ color: @navbar-link-disabled-color;
+ background-color: @navbar-link-disabled-bg;
+ }
+ }
+ }
+ }
+
+}
+
+
// Navbar form
+//
+// Extension of the `.form-inline` with some extra flavor for optimum display in
+// our navbars.
+
.navbar-form {
+ width: 100%; // Counteract the float from `.pull-` classes
+ padding: 10px @navbar-padding-horizontal;
+ border-top: 1px solid darken(@navbar-bg, 7%);
+ border-bottom: 1px solid darken(@navbar-bg, 7%);
+
+ // Mixin behavior for optimum display
.form-inline();
- .navbar-vertical-align(@input-height-base); // Vertically center in navbar
+
+ .form-group {
+ @media (max-width: @screen-phone-max) {
+ margin-bottom: 5px;
+ }
+ }
+
+ // Vertically center in expanded, horizontal navbar
+ .navbar-vertical-align(@input-height-base);
+
+ // Undo 100% width for pull classes
+ @media (min-width: @grid-float-breakpoint) {
+ width: auto;
+ border: 0;
+ padding-top: 0;
+ padding-bottom: 0;
+ }
}
+
// Dropdown menus
// Menu position and menu carets
@@ -285,6 +387,10 @@
}
}
+ .navbar-collapse {
+ border-top-color: darken(@navbar-inverse-bg, 7%);
+ }
+
// Dropdowns
.navbar-nav {
> .open > a {
@@ -323,11 +429,6 @@
@media screen and (min-width: @grid-float-breakpoint) {
- // Undo clearing to keep nav and brand horizontal
- .nav-collapse {
- clear: none;
- }
-
.navbar-nav {
float: left;
// undo margin to make nav extend full height of navbar
@@ -337,7 +438,8 @@
> li {
float: left;
> a {
- border-radius: 0;
+ padding-top: ((@navbar-height - @line-height-computed) / 2);
+ padding-bottom: ((@navbar-height - @line-height-computed) / 2);
}
}
@@ -353,7 +455,7 @@
left: auto;
display: none;
}
- .nav-collapse.collapse {
+ .navbar-collapse.collapse {
display: block !important;
height: auto !important;
padding-bottom: 0; // Override default setting