navbar.less 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. // stylelint-disable selector-max-type, selector-max-compound-selectors, selector-max-combinators, selector-max-class, declaration-no-important, selector-no-qualifying-type
  2. //
  3. // Navbars
  4. // --------------------------------------------------
  5. // Wrapper and base class
  6. //
  7. // Provide a static navbar from which we expand to create full-width, fixed, and
  8. // other navbar variations.
  9. .navbar {
  10. position: relative;
  11. min-height: @navbar-height; // Ensure a navbar always shows (e.g., without a .navbar-brand in collapsed mode)
  12. margin-bottom: @navbar-margin-bottom;
  13. border: 1px solid transparent;
  14. // Prevent floats from breaking the navbar
  15. &:extend(.clearfix all);
  16. @media (min-width: @grid-float-breakpoint) {
  17. border-radius: @navbar-border-radius;
  18. }
  19. }
  20. // Navbar heading
  21. //
  22. // Groups `.navbar-brand` and `.navbar-toggle` into a single component for easy
  23. // styling of responsive aspects.
  24. .navbar-header {
  25. &:extend(.clearfix all);
  26. @media (min-width: @grid-float-breakpoint) {
  27. float: left;
  28. }
  29. }
  30. // Navbar collapse (body)
  31. //
  32. // Group your navbar content into this for easy collapsing and expanding across
  33. // various device sizes. By default, this content is collapsed when <768px, but
  34. // will expand past that for a horizontal display.
  35. //
  36. // To start (on mobile devices) the navbar links, forms, and buttons are stacked
  37. // vertically and include a `max-height` to overflow in case you have too much
  38. // content for the user's viewport.
  39. .navbar-collapse {
  40. padding-right: @navbar-padding-horizontal;
  41. padding-left: @navbar-padding-horizontal;
  42. overflow-x: visible;
  43. border-top: 1px solid transparent;
  44. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  45. &:extend(.clearfix all);
  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-right: 0;
  69. padding-left: 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. // Fix the top/bottom navbars when screen real estate supports it
  82. position: fixed;
  83. right: 0;
  84. left: 0;
  85. z-index: @zindex-navbar-fixed;
  86. // Undo the rounded corners
  87. @media (min-width: @grid-float-breakpoint) {
  88. border-radius: 0;
  89. }
  90. }
  91. .navbar-fixed-top {
  92. top: 0;
  93. border-width: 0 0 1px;
  94. }
  95. .navbar-fixed-bottom {
  96. bottom: 0;
  97. margin-bottom: 0; // override .navbar defaults
  98. border-width: 1px 0 0;
  99. }
  100. // Both navbar header and collapse
  101. //
  102. // When a container is present, change the behavior of the header and collapse.
  103. .container,
  104. .container-fluid {
  105. > .navbar-header,
  106. > .navbar-collapse {
  107. margin-right: -@navbar-padding-horizontal;
  108. margin-left: -@navbar-padding-horizontal;
  109. @media (min-width: @grid-float-breakpoint) {
  110. margin-right: 0;
  111. margin-left: 0;
  112. }
  113. }
  114. }
  115. //
  116. // Navbar alignment options
  117. //
  118. // Display the navbar across the entirety of the page or fixed it to the top or
  119. // bottom of the page.
  120. // Static top (unfixed, but 100% wide) navbar
  121. .navbar-static-top {
  122. z-index: @zindex-navbar;
  123. border-width: 0 0 1px;
  124. @media (min-width: @grid-float-breakpoint) {
  125. border-radius: 0;
  126. }
  127. }
  128. // Brand/project name
  129. .navbar-brand {
  130. float: left;
  131. height: @navbar-height;
  132. padding: @navbar-padding-vertical @navbar-padding-horizontal;
  133. font-size: @font-size-large;
  134. line-height: @line-height-computed;
  135. &:hover,
  136. &:focus {
  137. text-decoration: none;
  138. }
  139. > img {
  140. display: block;
  141. }
  142. @media (min-width: @grid-float-breakpoint) {
  143. .navbar > .container &,
  144. .navbar > .container-fluid & {
  145. margin-left: -@navbar-padding-horizontal;
  146. }
  147. }
  148. }
  149. // Navbar toggle
  150. //
  151. // Custom button for toggling the `.navbar-collapse`, powered by the collapse
  152. // JavaScript plugin.
  153. .navbar-toggle {
  154. position: relative;
  155. float: right;
  156. padding: 9px 10px;
  157. margin-right: @navbar-padding-horizontal;
  158. .navbar-vertical-align(34px);
  159. background-color: transparent;
  160. background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  161. border: 1px solid transparent;
  162. border-radius: @border-radius-base;
  163. // We remove the `outline` here, but later compensate by attaching `:hover`
  164. // styles to `:focus`.
  165. &:focus {
  166. outline: 0;
  167. }
  168. // Bars
  169. .icon-bar {
  170. display: block;
  171. width: 22px;
  172. height: 2px;
  173. border-radius: 1px;
  174. }
  175. .icon-bar + .icon-bar {
  176. margin-top: 4px;
  177. }
  178. @media (min-width: @grid-float-breakpoint) {
  179. display: none;
  180. }
  181. }
  182. // Navbar nav links
  183. //
  184. // Builds on top of the `.nav` components with its own modifier class to make
  185. // the nav the full height of the horizontal nav (above 768px).
  186. .navbar-nav {
  187. margin: (@navbar-padding-vertical / 2) -@navbar-padding-horizontal;
  188. > li > a {
  189. padding-top: 10px;
  190. padding-bottom: 10px;
  191. line-height: @line-height-computed;
  192. }
  193. @media (max-width: @grid-float-breakpoint-max) {
  194. // Dropdowns get custom display when collapsed
  195. .open .dropdown-menu {
  196. position: static;
  197. float: none;
  198. width: auto;
  199. margin-top: 0;
  200. background-color: transparent;
  201. border: 0;
  202. box-shadow: none;
  203. > li > a,
  204. .dropdown-header {
  205. padding: 5px 15px 5px 25px;
  206. }
  207. > li > a {
  208. line-height: @line-height-computed;
  209. &:hover,
  210. &:focus {
  211. background-image: none;
  212. }
  213. }
  214. }
  215. }
  216. // Uncollapse the nav
  217. @media (min-width: @grid-float-breakpoint) {
  218. float: left;
  219. margin: 0;
  220. > li {
  221. float: left;
  222. > a {
  223. padding-top: @navbar-padding-vertical;
  224. padding-bottom: @navbar-padding-vertical;
  225. }
  226. }
  227. }
  228. }
  229. // Navbar form
  230. //
  231. // Extension of the `.form-inline` with some extra flavor for optimum display in
  232. // our navbars.
  233. .navbar-form {
  234. padding: 10px @navbar-padding-horizontal;
  235. margin-right: -@navbar-padding-horizontal;
  236. margin-left: -@navbar-padding-horizontal;
  237. border-top: 1px solid transparent;
  238. border-bottom: 1px solid transparent;
  239. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
  240. // Mixin behavior for optimum display
  241. .form-inline();
  242. .form-group {
  243. @media (max-width: @grid-float-breakpoint-max) {
  244. margin-bottom: 5px;
  245. &:last-child {
  246. margin-bottom: 0;
  247. }
  248. }
  249. }
  250. // Vertically center in expanded, horizontal navbar
  251. .navbar-vertical-align(@input-height-base);
  252. // Undo 100% width for pull classes
  253. @media (min-width: @grid-float-breakpoint) {
  254. width: auto;
  255. padding-top: 0;
  256. padding-bottom: 0;
  257. margin-right: 0;
  258. margin-left: 0;
  259. border: 0;
  260. box-shadow: none;
  261. }
  262. }
  263. // Dropdown menus
  264. // Menu position and menu carets
  265. .navbar-nav > li > .dropdown-menu {
  266. margin-top: 0;
  267. border-top-left-radius: 0;
  268. border-top-right-radius: 0;
  269. }
  270. // Menu position and menu caret support
  271. .navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
  272. margin-bottom: 0;
  273. border-top-left-radius: @navbar-border-radius;
  274. border-top-right-radius: @navbar-border-radius;
  275. border-bottom-right-radius: 0;
  276. border-bottom-left-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-right: @navbar-padding-horizontal;
  298. margin-left: @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 {
  310. .pull-left();
  311. }
  312. .navbar-right {
  313. .pull-right();
  314. margin-right: -@navbar-padding-horizontal;
  315. ~ .navbar-right {
  316. margin-right: 0;
  317. }
  318. }
  319. }
  320. // Alternate navbars
  321. // --------------------------------------------------
  322. // Default navbar
  323. .navbar-default {
  324. background-color: @navbar-default-bg;
  325. border-color: @navbar-default-border;
  326. .navbar-brand {
  327. color: @navbar-default-brand-color;
  328. &:hover,
  329. &:focus {
  330. color: @navbar-default-brand-hover-color;
  331. background-color: @navbar-default-brand-hover-bg;
  332. }
  333. }
  334. .navbar-text {
  335. color: @navbar-default-color;
  336. }
  337. .navbar-nav {
  338. > li > a {
  339. color: @navbar-default-link-color;
  340. &:hover,
  341. &:focus {
  342. color: @navbar-default-link-hover-color;
  343. background-color: @navbar-default-link-hover-bg;
  344. }
  345. }
  346. > .active > a {
  347. &,
  348. &:hover,
  349. &:focus {
  350. color: @navbar-default-link-active-color;
  351. background-color: @navbar-default-link-active-bg;
  352. }
  353. }
  354. > .disabled > a {
  355. &,
  356. &:hover,
  357. &:focus {
  358. color: @navbar-default-link-disabled-color;
  359. background-color: @navbar-default-link-disabled-bg;
  360. }
  361. }
  362. // Dropdown menu items
  363. // Remove background color from open dropdown
  364. > .open > a {
  365. &,
  366. &:hover,
  367. &:focus {
  368. color: @navbar-default-link-active-color;
  369. background-color: @navbar-default-link-active-bg;
  370. }
  371. }
  372. @media (max-width: @grid-float-breakpoint-max) {
  373. // Dropdowns get custom display when collapsed
  374. .open .dropdown-menu {
  375. > li > a {
  376. color: @navbar-default-link-color;
  377. &:hover,
  378. &:focus {
  379. color: @navbar-default-link-hover-color;
  380. background-color: @navbar-default-link-hover-bg;
  381. }
  382. }
  383. > .active > a {
  384. &,
  385. &:hover,
  386. &:focus {
  387. color: @navbar-default-link-active-color;
  388. background-color: @navbar-default-link-active-bg;
  389. }
  390. }
  391. > .disabled > a {
  392. &,
  393. &:hover,
  394. &:focus {
  395. color: @navbar-default-link-disabled-color;
  396. background-color: @navbar-default-link-disabled-bg;
  397. }
  398. }
  399. }
  400. }
  401. }
  402. .navbar-toggle {
  403. border-color: @navbar-default-toggle-border-color;
  404. &:hover,
  405. &:focus {
  406. background-color: @navbar-default-toggle-hover-bg;
  407. }
  408. .icon-bar {
  409. background-color: @navbar-default-toggle-icon-bar-bg;
  410. }
  411. }
  412. .navbar-collapse,
  413. .navbar-form {
  414. border-color: @navbar-default-border;
  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. // Dropdowns
  481. > .open > a {
  482. &,
  483. &:hover,
  484. &:focus {
  485. color: @navbar-inverse-link-active-color;
  486. background-color: @navbar-inverse-link-active-bg;
  487. }
  488. }
  489. @media (max-width: @grid-float-breakpoint-max) {
  490. // Dropdowns get custom display
  491. .open .dropdown-menu {
  492. > .dropdown-header {
  493. border-color: @navbar-inverse-border;
  494. }
  495. .divider {
  496. background-color: @navbar-inverse-border;
  497. }
  498. > li > a {
  499. color: @navbar-inverse-link-color;
  500. &:hover,
  501. &:focus {
  502. color: @navbar-inverse-link-hover-color;
  503. background-color: @navbar-inverse-link-hover-bg;
  504. }
  505. }
  506. > .active > a {
  507. &,
  508. &:hover,
  509. &:focus {
  510. color: @navbar-inverse-link-active-color;
  511. background-color: @navbar-inverse-link-active-bg;
  512. }
  513. }
  514. > .disabled > a {
  515. &,
  516. &:hover,
  517. &:focus {
  518. color: @navbar-inverse-link-disabled-color;
  519. background-color: @navbar-inverse-link-disabled-bg;
  520. }
  521. }
  522. }
  523. }
  524. }
  525. // Darken the responsive nav toggle
  526. .navbar-toggle {
  527. border-color: @navbar-inverse-toggle-border-color;
  528. &:hover,
  529. &:focus {
  530. background-color: @navbar-inverse-toggle-hover-bg;
  531. }
  532. .icon-bar {
  533. background-color: @navbar-inverse-toggle-icon-bar-bg;
  534. }
  535. }
  536. .navbar-collapse,
  537. .navbar-form {
  538. border-color: darken(@navbar-inverse-bg, 7%);
  539. }
  540. .navbar-link {
  541. color: @navbar-inverse-link-color;
  542. &:hover {
  543. color: @navbar-inverse-link-hover-color;
  544. }
  545. }
  546. .btn-link {
  547. color: @navbar-inverse-link-color;
  548. &:hover,
  549. &:focus {
  550. color: @navbar-inverse-link-hover-color;
  551. }
  552. &[disabled],
  553. fieldset[disabled] & {
  554. &:hover,
  555. &:focus {
  556. color: @navbar-inverse-link-disabled-color;
  557. }
  558. }
  559. }
  560. }