navbar.less 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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. max-height: @navbar-collapse-max-height;
  40. overflow-x: visible;
  41. padding-right: @navbar-padding-horizontal;
  42. padding-left: @navbar-padding-horizontal;
  43. &:extend(.clearfix all);
  44. -webkit-overflow-scrolling: touch;
  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: 1;
  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. background-color: transparent;
  187. background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  188. border: 2px solid @navbar-default-link-color;
  189. border-radius: @border-radius-base;
  190. // We remove the `outline` here, but later compensate by attaching `:hover`
  191. // styles to `:focus`.
  192. &:focus {
  193. outline: none;
  194. }
  195. @media (min-width: @grid-float-breakpoint) {
  196. display: none;
  197. }
  198. }
  199. // Navbar nav links
  200. //
  201. // Builds on top of the `.nav` components with its own modifier class to make
  202. // the nav the full height of the horizontal nav (above 768px).
  203. .navbar-nav {
  204. margin: (@navbar-padding-vertical / 2) -@navbar-padding-horizontal;
  205. > li > a {
  206. padding-top: 10px;
  207. padding-bottom: 10px;
  208. line-height: @line-height-computed;
  209. }
  210. @media (max-width: @grid-float-breakpoint-max) {
  211. margin: (@navbar-padding-vertical / 2) 0;
  212. // Dropdowns get custom display when collapsed
  213. .open .dropdown-menu {
  214. position: static;
  215. float: none;
  216. width: auto;
  217. margin-top: 0;
  218. background-color: transparent;
  219. border: 0;
  220. box-shadow: none;
  221. > li > a,
  222. > li > div.subdued,
  223. > li > form > button,
  224. .dropdown-header {
  225. padding: 5px 15px 5px 25px;
  226. }
  227. > li > a,
  228. > li > form > button {
  229. line-height: @line-height-computed;
  230. &:hover,
  231. &:focus {
  232. background-image: none;
  233. }
  234. }
  235. > li > div.subdued {
  236. line-height: @line-height-computed;
  237. }
  238. }
  239. }
  240. // Uncollapse the nav
  241. @media (min-width: @grid-float-breakpoint) {
  242. float: left;
  243. margin: 0;
  244. > li {
  245. float: left;
  246. > a {
  247. padding-top: @navbar-padding-vertical;
  248. padding-bottom: @navbar-padding-vertical;
  249. }
  250. }
  251. &.navbar-right:last-child {
  252. margin-right: -@navbar-padding-horizontal;
  253. }
  254. }
  255. }
  256. // Component alignment
  257. //
  258. // Repurpose the pull utilities as their own navbar utilities to avoid specificity
  259. // issues with parents and chaining. Only do this when the navbar is uncollapsed
  260. // though so that navbar contents properly stack and align in mobile.
  261. @media (min-width: @grid-float-breakpoint) {
  262. .navbar-left {
  263. .pull-left();
  264. }
  265. .navbar-right {
  266. .pull-right();
  267. }
  268. }
  269. // Navbar form
  270. //
  271. // Extension of the `.form-inline` with some extra flavor for optimum display in
  272. // our navbars.
  273. .navbar-form {
  274. margin-left: -@navbar-padding-horizontal;
  275. margin-right: -@navbar-padding-horizontal;
  276. padding: 10px @navbar-padding-horizontal;
  277. border-top: 1px solid transparent;
  278. border-bottom: 1px solid transparent;
  279. @shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1),
  280. 0 1px 0 rgba(255, 255, 255, 0.1);
  281. .box-shadow(@shadow);
  282. // Mixin behavior for optimum display
  283. .form-inline();
  284. .form-group {
  285. @media (max-width: @grid-float-breakpoint-max) {
  286. margin-bottom: 5px;
  287. }
  288. }
  289. // Vertically center in expanded, horizontal navbar
  290. .navbar-vertical-align(@input-height-base);
  291. // Undo 100% width for pull classes
  292. @media (min-width: @grid-float-breakpoint) {
  293. width: auto;
  294. border: 0;
  295. margin-left: 0;
  296. margin-right: 0;
  297. padding-top: 0;
  298. padding-bottom: 0;
  299. .box-shadow(none);
  300. // Outdent the form if last child to line up with content down the page
  301. &.navbar-right:last-child {
  302. margin-right: -@navbar-padding-horizontal;
  303. }
  304. }
  305. }
  306. // Dropdown menus
  307. // Menu position and menu carets
  308. .navbar-nav > li > .dropdown-menu {
  309. margin-top: 0;
  310. .border-top-radius(0);
  311. }
  312. // Menu position and menu caret support for dropups via extra dropup class
  313. .navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
  314. .border-bottom-radius(0);
  315. }
  316. // Buttons in navbars
  317. //
  318. // Vertically center a button within a navbar (when *not* in a form).
  319. .navbar-btn {
  320. .navbar-vertical-align(@input-height-base);
  321. &.btn-sm {
  322. .navbar-vertical-align(@input-height-small);
  323. }
  324. &.btn-xs {
  325. .navbar-vertical-align(22);
  326. }
  327. }
  328. // Text in navbars
  329. //
  330. // Add a class to make any element properly align itself vertically within the navbars.
  331. .navbar-text {
  332. .navbar-vertical-align(@line-height-computed);
  333. @media (min-width: @grid-float-breakpoint) {
  334. float: left;
  335. margin-left: @navbar-padding-horizontal;
  336. margin-right: @navbar-padding-horizontal;
  337. // Outdent the form if last child to line up with content down the page
  338. &.navbar-right:last-child {
  339. margin-right: 0;
  340. }
  341. }
  342. }
  343. // Alternate navbars
  344. // --------------------------------------------------
  345. // Default navbar
  346. .navbar-default {
  347. background-color: @navbar-default-bg;
  348. border-color: @navbar-default-border;
  349. padding: @navbar-default-padding;
  350. position: absolute;
  351. top: 0;
  352. width: 100%;
  353. height: @header-height;
  354. .navbar-brand {
  355. position: absolute;
  356. top: 5px;
  357. bottom: 5px;
  358. width: @navbar-brand-width;
  359. padding: 0;
  360. background-image: @navbar-brand-image-url;
  361. background-size: contain;
  362. background-repeat: no-repeat;
  363. background-position: left center;
  364. }
  365. .navbar-text {
  366. color: @navbar-default-color;
  367. }
  368. .navbar-nav {
  369. > li > a {
  370. color: @navbar-default-link-color;
  371. border: 2px solid transparent;
  372. font-size: @navbar-btn-font-size;
  373. font-weight: @navbar-btn-font-weight;
  374. line-height: @navbar-btn-line-height;
  375. background-color: @navbar-default-link-bg;
  376. @media (min-width: @grid-float-breakpoint) {
  377. border-radius: @navbar-btn-border-radius;
  378. padding: @navbar-btn-padding;
  379. }
  380. &:hover,
  381. &:focus {
  382. color: #fff;
  383. background-color: @navbar-default-link-hover-bg;
  384. border: 2px solid @navbar-default-link-hover-color;
  385. }
  386. }
  387. > .active > a {
  388. &,
  389. &:hover,
  390. &:focus {
  391. color: @navbar-default-link-active-color;
  392. background-color: @navbar-default-link-active-bg;
  393. }
  394. }
  395. > .disabled > a {
  396. &,
  397. &:hover,
  398. &:focus {
  399. color: @navbar-default-link-disabled-color;
  400. background-color: @navbar-default-link-disabled-bg;
  401. }
  402. }
  403. > li.subdued > a {
  404. border: 0;
  405. color: @navbar-subdued-color;
  406. margin-left: 0;
  407. background-color: transparent;
  408. &:hover,
  409. &:focus {
  410. color: @navbar-subdued-hover-color;
  411. background-color: @navbar-subdued-hover-bg;
  412. }
  413. &:focus {
  414. .tab-focus();
  415. }
  416. @media (min-width: @grid-float-breakpoint) {
  417. padding: @navbar-subdued-padding;
  418. }
  419. }
  420. @media (min-width: @grid-float-breakpoint) {
  421. > li > a {
  422. border-color: @navbar-default-link-border-color;
  423. margin-left: 1rem;
  424. }
  425. }
  426. }
  427. .navbar-toggle {
  428. border-color: @navbar-default-toggle-border-color;
  429. color: @navbar-default-link-color;
  430. &:hover,
  431. &.active {
  432. background-color: @navbar-default-toggle-hover-bg;
  433. border-color: @navbar-default-toggle-hover-bg;
  434. color: #fff;
  435. }
  436. }
  437. .navbar-collapse,
  438. .navbar-form {
  439. border-color: @navbar-default-border;
  440. }
  441. .navbar-collapse.in {
  442. box-shadow: 0 10px 15px rgba(0, 0, 0, 0.25);
  443. }
  444. // Dropdown menu items
  445. .navbar-nav {
  446. // Remove background color from open dropdown
  447. > .open > a {
  448. &,
  449. &:hover,
  450. &:focus {
  451. background-color: @navbar-default-link-active-bg;
  452. color: @navbar-default-link-active-color;
  453. }
  454. }
  455. > .open.subdued > a {
  456. &,
  457. &:hover,
  458. &:focus {
  459. color: @navbar-subdued-hover-color;
  460. background-color: @navbar-subdued-hover-bg;
  461. }
  462. }
  463. @media (max-width: @grid-float-breakpoint-max) {
  464. // Dropdowns get custom display when collapsed
  465. .open .dropdown-menu {
  466. background-color: lighten(@navbar-default-bg, 10%);
  467. > li > div.subdued {
  468. color: mix(@navbar-default-link-color, @navbar-default-bg);
  469. }
  470. > li > a,
  471. > li > form > button {
  472. // padding: 12px 12px 13px 30px;
  473. color: @navbar-default-link-color;
  474. &:hover,
  475. &:focus {
  476. color: #fff;
  477. background-color: @navbar-default-link-hover-bg;
  478. }
  479. }
  480. > .active > a,
  481. > .active > form > button {
  482. &,
  483. &:hover,
  484. &:focus {
  485. color: @navbar-default-link-active-color;
  486. background-color: @navbar-default-link-active-bg;
  487. }
  488. }
  489. > .disabled > a,
  490. > .disabled > form > button {
  491. &,
  492. &:hover,
  493. &:focus {
  494. color: @navbar-default-link-disabled-color;
  495. background-color: @navbar-default-link-disabled-bg;
  496. }
  497. }
  498. }
  499. }
  500. }
  501. // Links in navbars
  502. //
  503. // Add a class to ensure links outside the navbar nav are colored correctly.
  504. .navbar-link {
  505. color: @navbar-default-link-color;
  506. &:hover {
  507. color: @navbar-default-link-hover-color;
  508. }
  509. }
  510. @media (min-width: @grid-float-breakpoint) {
  511. padding: @navbar-default-padding-v 0;
  512. }
  513. }