navbar.less 13 KB

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