navbar.less 14 KB

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