navbar.less 14 KB

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