_navbar.scss 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. //
  2. // Navbars
  3. // --------------------------------------------------
  4. // Wrapper and base class
  5. //
  6. // Provide a static navbar from which we expand to create full-width, fixed, and
  7. // other navbar variations.
  8. .navbar {
  9. position: relative;
  10. min-height: $navbar-height; // Ensure a navbar always shows (e.g., without a .navbar-brand in collapsed mode)
  11. margin-bottom: $navbar-margin-bottom;
  12. border: 1px solid transparent;
  13. // Prevent floats from breaking the navbar
  14. @include clearfix();
  15. @media (min-width: $grid-float-breakpoint) {
  16. border-radius: $navbar-border-radius;
  17. }
  18. }
  19. // Navbar heading
  20. //
  21. // Groups `.navbar-brand` and `.navbar-toggle` into a single component for easy
  22. // styling of responsive aspects.
  23. .navbar-header {
  24. @include clearfix();
  25. @media (min-width: $grid-float-breakpoint) {
  26. float: left;
  27. }
  28. }
  29. // Navbar collapse (body)
  30. //
  31. // Group your navbar content into this for easy collapsing and expanding across
  32. // various device sizes. By default, this content is collapsed when <768px, but
  33. // will expand past that for a horizontal display.
  34. //
  35. // To start (on mobile devices) the navbar links, forms, and buttons are stacked
  36. // vertically and include a `max-height` to overflow in case you have too much
  37. // content for the user's viewport.
  38. .navbar-collapse {
  39. max-height: $navbar-collapse-max-height;
  40. overflow-x: visible;
  41. padding-right: $navbar-padding-horizontal;
  42. padding-left: $navbar-padding-horizontal;
  43. border-top: 1px solid transparent;
  44. box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
  45. @include clearfix();
  46. -webkit-overflow-scrolling: touch;
  47. &.in {
  48. overflow-y: auto;
  49. }
  50. @media (min-width: $grid-float-breakpoint) {
  51. width: auto;
  52. border-top: 0;
  53. box-shadow: none;
  54. &.collapse {
  55. display: block !important;
  56. height: auto !important;
  57. padding-bottom: 0; // Override default setting
  58. overflow: visible !important;
  59. }
  60. &.in {
  61. overflow-y: visible;
  62. }
  63. // Undo the collapse side padding for navbars with containers to ensure
  64. // alignment of right-aligned contents.
  65. .navbar-fixed-top &,
  66. .navbar-static-top &,
  67. .navbar-fixed-bottom & {
  68. padding-left: 0;
  69. padding-right: 0;
  70. }
  71. }
  72. }
  73. // Both navbar header and collapse
  74. //
  75. // When a container is present, change the behavior of the header and collapse.
  76. .container,
  77. .container-fluid {
  78. > .navbar-header,
  79. > .navbar-collapse {
  80. margin-right: -$navbar-padding-horizontal;
  81. margin-left: -$navbar-padding-horizontal;
  82. @media (min-width: $grid-float-breakpoint) {
  83. margin-right: 0;
  84. margin-left: 0;
  85. }
  86. }
  87. }
  88. //
  89. // Navbar alignment options
  90. //
  91. // Display the navbar across the entirety of the page or fixed it to the top or
  92. // bottom of the page.
  93. // Static top (unfixed, but 100% wide) navbar
  94. .navbar-static-top {
  95. z-index: $zindex-navbar;
  96. border-width: 0 0 1px;
  97. @media (min-width: $grid-float-breakpoint) {
  98. border-radius: 0;
  99. }
  100. }
  101. // Fix the top/bottom navbars when screen real estate supports it
  102. .navbar-fixed-top,
  103. .navbar-fixed-bottom {
  104. position: fixed;
  105. right: 0;
  106. left: 0;
  107. z-index: $zindex-navbar-fixed;
  108. // Undo the rounded corners
  109. @media (min-width: $grid-float-breakpoint) {
  110. border-radius: 0;
  111. }
  112. }
  113. .navbar-fixed-top {
  114. top: 0;
  115. border-width: 0 0 1px;
  116. }
  117. .navbar-fixed-bottom {
  118. bottom: 0;
  119. margin-bottom: 0; // override .navbar defaults
  120. border-width: 1px 0 0;
  121. }
  122. // Brand/project name
  123. .navbar-brand {
  124. float: left;
  125. padding: $navbar-padding-vertical $navbar-padding-horizontal;
  126. font-size: $font-size-large;
  127. line-height: $line-height-computed;
  128. height: $navbar-height;
  129. &:hover,
  130. &:focus {
  131. text-decoration: none;
  132. }
  133. @media (min-width: $grid-float-breakpoint) {
  134. .navbar > .container &,
  135. .navbar > .container-fluid & {
  136. margin-left: -$navbar-padding-horizontal;
  137. }
  138. }
  139. }
  140. // Navbar toggle
  141. //
  142. // Custom button for toggling the `.navbar-collapse`, powered by the collapse
  143. // JavaScript plugin.
  144. .navbar-toggle {
  145. position: relative;
  146. float: right;
  147. margin-right: $navbar-padding-horizontal;
  148. padding: 9px 10px;
  149. @include navbar-vertical-align(34px);
  150. background-color: transparent;
  151. background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  152. border: 1px solid transparent;
  153. border-radius: $border-radius-base;
  154. // We remove the `outline` here, but later compensate by attaching `:hover`
  155. // styles to `:focus`.
  156. &:focus {
  157. outline: none;
  158. }
  159. // Bars
  160. .icon-bar {
  161. display: block;
  162. width: 22px;
  163. height: 2px;
  164. border-radius: 1px;
  165. }
  166. .icon-bar + .icon-bar {
  167. margin-top: 4px;
  168. }
  169. @media (min-width: $grid-float-breakpoint) {
  170. display: none;
  171. }
  172. }
  173. // Navbar nav links
  174. //
  175. // Builds on top of the `.nav` components with its own modifier class to make
  176. // the nav the full height of the horizontal nav (above 768px).
  177. .navbar-nav {
  178. margin: ($navbar-padding-vertical / 2) (-$navbar-padding-horizontal);
  179. > li > a {
  180. padding-top: 10px;
  181. padding-bottom: 10px;
  182. line-height: $line-height-computed;
  183. }
  184. @media (max-width: $grid-float-breakpoint-max) {
  185. // Dropdowns get custom display when collapsed
  186. .open .dropdown-menu {
  187. position: static;
  188. float: none;
  189. width: auto;
  190. margin-top: 0;
  191. background-color: transparent;
  192. border: 0;
  193. box-shadow: none;
  194. > li > a,
  195. .dropdown-header {
  196. padding: 5px 15px 5px 25px;
  197. }
  198. > li > a {
  199. line-height: $line-height-computed;
  200. &:hover,
  201. &:focus {
  202. background-image: none;
  203. }
  204. }
  205. }
  206. }
  207. // Uncollapse the nav
  208. @media (min-width: $grid-float-breakpoint) {
  209. float: left;
  210. margin: 0;
  211. > li {
  212. float: left;
  213. > a {
  214. padding-top: $navbar-padding-vertical;
  215. padding-bottom: $navbar-padding-vertical;
  216. }
  217. }
  218. &.navbar-right:last-child {
  219. margin-right: -$navbar-padding-horizontal;
  220. }
  221. }
  222. }
  223. // Component alignment
  224. //
  225. // Repurpose the pull utilities as their own navbar utilities to avoid specificity
  226. // issues with parents and chaining. Only do this when the navbar is uncollapsed
  227. // though so that navbar contents properly stack and align in mobile.
  228. @media (min-width: $grid-float-breakpoint) {
  229. .navbar-left {
  230. float: left !important;
  231. }
  232. .navbar-right {
  233. float: right !important;
  234. }
  235. }
  236. // Navbar form
  237. //
  238. // Extension of the `.form-inline` with some extra flavor for optimum display in
  239. // our navbars.
  240. .navbar-form {
  241. margin-left: -$navbar-padding-horizontal;
  242. margin-right: -$navbar-padding-horizontal;
  243. padding: 10px $navbar-padding-horizontal;
  244. border-top: 1px solid transparent;
  245. border-bottom: 1px solid transparent;
  246. $shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.1);
  247. @include box-shadow($shadow);
  248. // Mixin behavior for optimum display
  249. @extend .form-inline;
  250. .form-group {
  251. @media (max-width: $grid-float-breakpoint-max) {
  252. margin-bottom: 5px;
  253. }
  254. }
  255. // Vertically center in expanded, horizontal navbar
  256. @include navbar-vertical-align($input-height-base);
  257. // Undo 100% width for pull classes
  258. @media (min-width: $grid-float-breakpoint) {
  259. width: auto;
  260. border: 0;
  261. margin-left: 0;
  262. margin-right: 0;
  263. padding-top: 0;
  264. padding-bottom: 0;
  265. @include box-shadow(none);
  266. // Outdent the form if last child to line up with content down the page
  267. &.navbar-right:last-child {
  268. margin-right: -$navbar-padding-horizontal;
  269. }
  270. }
  271. }
  272. // Dropdown menus
  273. // Menu position and menu carets
  274. .navbar-nav > li > .dropdown-menu {
  275. margin-top: 0;
  276. @include border-top-radius(0);
  277. }
  278. // Menu position and menu caret support for dropups via extra dropup class
  279. .navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
  280. @include border-bottom-radius(0);
  281. }
  282. // Buttons in navbars
  283. //
  284. // Vertically center a button within a navbar (when *not* in a form).
  285. .navbar-btn {
  286. @include navbar-vertical-align($input-height-base);
  287. &.btn-sm {
  288. @include navbar-vertical-align($input-height-small);
  289. }
  290. &.btn-xs {
  291. @include navbar-vertical-align(22);
  292. }
  293. }
  294. // Text in navbars
  295. //
  296. // Add a class to make any element properly align itself vertically within the navbars.
  297. .navbar-text {
  298. @include navbar-vertical-align($line-height-computed);
  299. @media (min-width: $grid-float-breakpoint) {
  300. float: left;
  301. margin-left: $navbar-padding-horizontal;
  302. margin-right: $navbar-padding-horizontal;
  303. // Outdent the form if last child to line up with content down the page
  304. &.navbar-right:last-child {
  305. margin-right: 0;
  306. }
  307. }
  308. }
  309. // Alternate navbars
  310. // --------------------------------------------------
  311. // Default navbar
  312. .navbar-default {
  313. background-color: $navbar-default-bg;
  314. border-color: $navbar-default-border;
  315. .navbar-brand {
  316. color: $navbar-default-brand-color;
  317. &:hover,
  318. &:focus {
  319. color: $navbar-default-brand-hover-color;
  320. background-color: $navbar-default-brand-hover-bg;
  321. }
  322. }
  323. .navbar-text {
  324. color: $navbar-default-color;
  325. }
  326. .navbar-nav {
  327. > li > a {
  328. color: $navbar-default-link-color;
  329. &:hover,
  330. &:focus {
  331. color: $navbar-default-link-hover-color;
  332. background-color: $navbar-default-link-hover-bg;
  333. }
  334. }
  335. > .active > a {
  336. &,
  337. &:hover,
  338. &:focus {
  339. color: $navbar-default-link-active-color;
  340. background-color: $navbar-default-link-active-bg;
  341. }
  342. }
  343. > .disabled > a {
  344. &,
  345. &:hover,
  346. &:focus {
  347. color: $navbar-default-link-disabled-color;
  348. background-color: $navbar-default-link-disabled-bg;
  349. }
  350. }
  351. }
  352. .navbar-toggle {
  353. border-color: $navbar-default-toggle-border-color;
  354. &:hover,
  355. &:focus {
  356. background-color: $navbar-default-toggle-hover-bg;
  357. }
  358. .icon-bar {
  359. background-color: $navbar-default-toggle-icon-bar-bg;
  360. }
  361. }
  362. .navbar-collapse,
  363. .navbar-form {
  364. border-color: $navbar-default-border;
  365. }
  366. // Dropdown menu items
  367. .navbar-nav {
  368. // Remove background color from open dropdown
  369. > .open > a {
  370. &,
  371. &:hover,
  372. &:focus {
  373. background-color: $navbar-default-link-active-bg;
  374. color: $navbar-default-link-active-color;
  375. }
  376. }
  377. @media (max-width: $grid-float-breakpoint-max) {
  378. // Dropdowns get custom display when collapsed
  379. .open .dropdown-menu {
  380. > li > a {
  381. color: $navbar-default-link-color;
  382. &:hover,
  383. &:focus {
  384. color: $navbar-default-link-hover-color;
  385. background-color: $navbar-default-link-hover-bg;
  386. }
  387. }
  388. > .active > a {
  389. &,
  390. &:hover,
  391. &:focus {
  392. color: $navbar-default-link-active-color;
  393. background-color: $navbar-default-link-active-bg;
  394. }
  395. }
  396. > .disabled > a {
  397. &,
  398. &:hover,
  399. &:focus {
  400. color: $navbar-default-link-disabled-color;
  401. background-color: $navbar-default-link-disabled-bg;
  402. }
  403. }
  404. }
  405. }
  406. }
  407. // Links in navbars
  408. //
  409. // Add a class to ensure links outside the navbar nav are colored correctly.
  410. .navbar-link {
  411. color: $navbar-default-link-color;
  412. &:hover {
  413. color: $navbar-default-link-hover-color;
  414. }
  415. }
  416. }
  417. // Inverse navbar
  418. .navbar-inverse {
  419. background-color: $navbar-inverse-bg;
  420. border-color: $navbar-inverse-border;
  421. .navbar-brand {
  422. color: $navbar-inverse-brand-color;
  423. &:hover,
  424. &:focus {
  425. color: $navbar-inverse-brand-hover-color;
  426. background-color: $navbar-inverse-brand-hover-bg;
  427. }
  428. }
  429. .navbar-text {
  430. color: $navbar-inverse-color;
  431. }
  432. .navbar-nav {
  433. > li > a {
  434. color: $navbar-inverse-link-color;
  435. &:hover,
  436. &:focus {
  437. color: $navbar-inverse-link-hover-color;
  438. background-color: $navbar-inverse-link-hover-bg;
  439. }
  440. }
  441. > .active > a {
  442. &,
  443. &:hover,
  444. &:focus {
  445. color: $navbar-inverse-link-active-color;
  446. background-color: $navbar-inverse-link-active-bg;
  447. }
  448. }
  449. > .disabled > a {
  450. &,
  451. &:hover,
  452. &:focus {
  453. color: $navbar-inverse-link-disabled-color;
  454. background-color: $navbar-inverse-link-disabled-bg;
  455. }
  456. }
  457. }
  458. // Darken the responsive nav toggle
  459. .navbar-toggle {
  460. border-color: $navbar-inverse-toggle-border-color;
  461. &:hover,
  462. &:focus {
  463. background-color: $navbar-inverse-toggle-hover-bg;
  464. }
  465. .icon-bar {
  466. background-color: $navbar-inverse-toggle-icon-bar-bg;
  467. }
  468. }
  469. .navbar-collapse,
  470. .navbar-form {
  471. border-color: darken($navbar-inverse-bg, 7%);
  472. }
  473. // Dropdowns
  474. .navbar-nav {
  475. > .open > a {
  476. &,
  477. &:hover,
  478. &:focus {
  479. background-color: $navbar-inverse-link-active-bg;
  480. color: $navbar-inverse-link-active-color;
  481. }
  482. }
  483. @media (max-width: $grid-float-breakpoint-max) {
  484. // Dropdowns get custom display
  485. .open .dropdown-menu {
  486. > .dropdown-header {
  487. border-color: $navbar-inverse-border;
  488. }
  489. .divider {
  490. background-color: $navbar-inverse-border;
  491. }
  492. > li > a {
  493. color: $navbar-inverse-link-color;
  494. &:hover,
  495. &:focus {
  496. color: $navbar-inverse-link-hover-color;
  497. background-color: $navbar-inverse-link-hover-bg;
  498. }
  499. }
  500. > .active > a {
  501. &,
  502. &:hover,
  503. &:focus {
  504. color: $navbar-inverse-link-active-color;
  505. background-color: $navbar-inverse-link-active-bg;
  506. }
  507. }
  508. > .disabled > a {
  509. &,
  510. &:hover,
  511. &:focus {
  512. color: $navbar-inverse-link-disabled-color;
  513. background-color: $navbar-inverse-link-disabled-bg;
  514. }
  515. }
  516. }
  517. }
  518. }
  519. .navbar-link {
  520. color: $navbar-inverse-link-color;
  521. &:hover {
  522. color: $navbar-inverse-link-hover-color;
  523. }
  524. }
  525. }