Нет описания

navbar.less 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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, .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. @shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1);
  240. .box-shadow(@shadow);
  241. // Mixin behavior for optimum display
  242. .form-inline();
  243. .form-group {
  244. @media (max-width: @grid-float-breakpoint-max) {
  245. margin-bottom: 5px;
  246. &:last-child {
  247. margin-bottom: 0;
  248. }
  249. }
  250. }
  251. // Vertically center in expanded, horizontal navbar
  252. .navbar-vertical-align(@input-height-base);
  253. // Undo 100% width for pull classes
  254. @media (min-width: @grid-float-breakpoint) {
  255. width: auto;
  256. padding-top: 0;
  257. padding-bottom: 0;
  258. margin-right: 0;
  259. margin-left: 0;
  260. border: 0;
  261. .box-shadow(none);
  262. }
  263. }
  264. // Dropdown menus
  265. // Menu position and menu carets
  266. .navbar-nav > li > .dropdown-menu {
  267. margin-top: 0;
  268. .border-top-radius(0);
  269. }
  270. // Menu position and menu caret support for dropups via extra dropup class
  271. .navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
  272. margin-bottom: 0;
  273. .border-top-radius(@navbar-border-radius);
  274. .border-bottom-radius(0);
  275. }
  276. // Buttons in navbars
  277. //
  278. // Vertically center a button within a navbar (when *not* in a form).
  279. .navbar-btn {
  280. .navbar-vertical-align(@input-height-base);
  281. &.btn-sm {
  282. .navbar-vertical-align(@input-height-small);
  283. }
  284. &.btn-xs {
  285. .navbar-vertical-align(22);
  286. }
  287. }
  288. // Text in navbars
  289. //
  290. // Add a class to make any element properly align itself vertically within the navbars.
  291. .navbar-text {
  292. .navbar-vertical-align(@line-height-computed);
  293. @media (min-width: @grid-float-breakpoint) {
  294. float: left;
  295. margin-right: @navbar-padding-horizontal;
  296. margin-left: @navbar-padding-horizontal;
  297. }
  298. }
  299. // Component alignment
  300. //
  301. // Repurpose the pull utilities as their own navbar utilities to avoid specificity
  302. // issues with parents and chaining. Only do this when the navbar is uncollapsed
  303. // though so that navbar contents properly stack and align in mobile.
  304. //
  305. // Declared after the navbar components to ensure more specificity on the margins.
  306. @media (min-width: @grid-float-breakpoint) {
  307. .navbar-left { .pull-left(); }
  308. .navbar-right {
  309. .pull-right();
  310. margin-right: -@navbar-padding-horizontal;
  311. ~ .navbar-right {
  312. margin-right: 0;
  313. }
  314. }
  315. }
  316. // Alternate navbars
  317. // --------------------------------------------------
  318. // Default navbar
  319. .navbar-default {
  320. background-color: @navbar-default-bg;
  321. border-color: @navbar-default-border;
  322. .navbar-brand {
  323. color: @navbar-default-brand-color;
  324. &:hover,
  325. &:focus {
  326. color: @navbar-default-brand-hover-color;
  327. background-color: @navbar-default-brand-hover-bg;
  328. }
  329. }
  330. .navbar-text {
  331. color: @navbar-default-color;
  332. }
  333. .navbar-nav {
  334. > li > a {
  335. color: @navbar-default-link-color;
  336. &:hover,
  337. &:focus {
  338. color: @navbar-default-link-hover-color;
  339. background-color: @navbar-default-link-hover-bg;
  340. }
  341. }
  342. > .active > a {
  343. &,
  344. &:hover,
  345. &:focus {
  346. color: @navbar-default-link-active-color;
  347. background-color: @navbar-default-link-active-bg;
  348. }
  349. }
  350. > .disabled > a {
  351. &,
  352. &:hover,
  353. &:focus {
  354. color: @navbar-default-link-disabled-color;
  355. background-color: @navbar-default-link-disabled-bg;
  356. }
  357. }
  358. // Dropdown menu items
  359. // Remove background color from open dropdown
  360. > .open > a {
  361. &,
  362. &:hover,
  363. &:focus {
  364. color: @navbar-default-link-active-color;
  365. background-color: @navbar-default-link-active-bg;
  366. }
  367. }
  368. @media (max-width: @grid-float-breakpoint-max) {
  369. // Dropdowns get custom display when collapsed
  370. .open .dropdown-menu {
  371. > li > a {
  372. color: @navbar-default-link-color;
  373. &:hover,
  374. &:focus {
  375. color: @navbar-default-link-hover-color;
  376. background-color: @navbar-default-link-hover-bg;
  377. }
  378. }
  379. > .active > a {
  380. &,
  381. &:hover,
  382. &:focus {
  383. color: @navbar-default-link-active-color;
  384. background-color: @navbar-default-link-active-bg;
  385. }
  386. }
  387. > .disabled > a {
  388. &,
  389. &:hover,
  390. &:focus {
  391. color: @navbar-default-link-disabled-color;
  392. background-color: @navbar-default-link-disabled-bg;
  393. }
  394. }
  395. }
  396. }
  397. }
  398. .navbar-toggle {
  399. border-color: @navbar-default-toggle-border-color;
  400. &:hover,
  401. &:focus {
  402. background-color: @navbar-default-toggle-hover-bg;
  403. }
  404. .icon-bar {
  405. background-color: @navbar-default-toggle-icon-bar-bg;
  406. }
  407. }
  408. .navbar-collapse,
  409. .navbar-form {
  410. border-color: @navbar-default-border;
  411. }
  412. // Links in navbars
  413. //
  414. // Add a class to ensure links outside the navbar nav are colored correctly.
  415. .navbar-link {
  416. color: @navbar-default-link-color;
  417. &:hover {
  418. color: @navbar-default-link-hover-color;
  419. }
  420. }
  421. .btn-link {
  422. color: @navbar-default-link-color;
  423. &:hover,
  424. &:focus {
  425. color: @navbar-default-link-hover-color;
  426. }
  427. &[disabled],
  428. fieldset[disabled] & {
  429. &:hover,
  430. &:focus {
  431. color: @navbar-default-link-disabled-color;
  432. }
  433. }
  434. }
  435. }
  436. // Inverse navbar
  437. .navbar-inverse {
  438. background-color: @navbar-inverse-bg;
  439. border-color: @navbar-inverse-border;
  440. .navbar-brand {
  441. color: @navbar-inverse-brand-color;
  442. &:hover,
  443. &:focus {
  444. color: @navbar-inverse-brand-hover-color;
  445. background-color: @navbar-inverse-brand-hover-bg;
  446. }
  447. }
  448. .navbar-text {
  449. color: @navbar-inverse-color;
  450. }
  451. .navbar-nav {
  452. > li > a {
  453. color: @navbar-inverse-link-color;
  454. &:hover,
  455. &:focus {
  456. color: @navbar-inverse-link-hover-color;
  457. background-color: @navbar-inverse-link-hover-bg;
  458. }
  459. }
  460. > .active > a {
  461. &,
  462. &:hover,
  463. &:focus {
  464. color: @navbar-inverse-link-active-color;
  465. background-color: @navbar-inverse-link-active-bg;
  466. }
  467. }
  468. > .disabled > a {
  469. &,
  470. &:hover,
  471. &:focus {
  472. color: @navbar-inverse-link-disabled-color;
  473. background-color: @navbar-inverse-link-disabled-bg;
  474. }
  475. }
  476. // Dropdowns
  477. > .open > a {
  478. &,
  479. &:hover,
  480. &:focus {
  481. color: @navbar-inverse-link-active-color;
  482. background-color: @navbar-inverse-link-active-bg;
  483. }
  484. }
  485. @media (max-width: @grid-float-breakpoint-max) {
  486. // Dropdowns get custom display
  487. .open .dropdown-menu {
  488. > .dropdown-header {
  489. border-color: @navbar-inverse-border;
  490. }
  491. .divider {
  492. background-color: @navbar-inverse-border;
  493. }
  494. > li > a {
  495. color: @navbar-inverse-link-color;
  496. &:hover,
  497. &:focus {
  498. color: @navbar-inverse-link-hover-color;
  499. background-color: @navbar-inverse-link-hover-bg;
  500. }
  501. }
  502. > .active > a {
  503. &,
  504. &:hover,
  505. &:focus {
  506. color: @navbar-inverse-link-active-color;
  507. background-color: @navbar-inverse-link-active-bg;
  508. }
  509. }
  510. > .disabled > a {
  511. &,
  512. &:hover,
  513. &:focus {
  514. color: @navbar-inverse-link-disabled-color;
  515. background-color: @navbar-inverse-link-disabled-bg;
  516. }
  517. }
  518. }
  519. }
  520. }
  521. // Darken the responsive nav toggle
  522. .navbar-toggle {
  523. border-color: @navbar-inverse-toggle-border-color;
  524. &:hover,
  525. &:focus {
  526. background-color: @navbar-inverse-toggle-hover-bg;
  527. }
  528. .icon-bar {
  529. background-color: @navbar-inverse-toggle-icon-bar-bg;
  530. }
  531. }
  532. .navbar-collapse,
  533. .navbar-form {
  534. border-color: darken(@navbar-inverse-bg, 7%);
  535. }
  536. .navbar-link {
  537. color: @navbar-inverse-link-color;
  538. &:hover {
  539. color: @navbar-inverse-link-hover-color;
  540. }
  541. }
  542. .btn-link {
  543. color: @navbar-inverse-link-color;
  544. &:hover,
  545. &:focus {
  546. color: @navbar-inverse-link-hover-color;
  547. }
  548. &[disabled],
  549. fieldset[disabled] & {
  550. &:hover,
  551. &:focus {
  552. color: @navbar-inverse-link-disabled-color;
  553. }
  554. }
  555. }
  556. }