navbar.less 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. //
  2. // Navbars (Redux)
  3. // --------------------------------------------------
  4. // COMMON STYLES
  5. // -------------
  6. // Base class and wrapper
  7. .navbar {
  8. overflow: visible;
  9. margin-bottom: @baseLineHeight;
  10. color: @navbarText;
  11. // Fix for IE7's bad z-indexing so dropdowns don't appear below content that follows the navbar
  12. *position: relative;
  13. *z-index: 2;
  14. }
  15. // Inner for background effects
  16. // Gradient is applied to its own element because overflow visible is not honored by IE when filter is present
  17. .navbar-inner {
  18. min-height: @navbarHeight;
  19. padding-left: 20px;
  20. padding-right: 20px;
  21. #gradient > .vertical(@navbarBackgroundHighlight, @navbarBackground);
  22. border: 1px solid @navbarBorder;
  23. .border-radius(4px);
  24. .box-shadow(0 1px 4px rgba(0,0,0,.065));
  25. // Prevent floats from breaking the navbar
  26. .clearfix();
  27. }
  28. // Set width to auto for default container
  29. // We then reset it for fixed navbars in the #gridSystem mixin
  30. .navbar .container {
  31. width: auto;
  32. }
  33. // Override the default collapsed state
  34. .nav-collapse.collapse {
  35. height: auto;
  36. }
  37. // Brand: website or project name
  38. // -------------------------
  39. .navbar .brand {
  40. float: left;
  41. display: block;
  42. // Vertically center the text given @navbarHeight
  43. padding: ((@navbarHeight - @baseLineHeight) / 2) 20px ((@navbarHeight - @baseLineHeight) / 2);
  44. margin-left: -20px; // negative indent to left-align the text down the page
  45. font-size: 20px;
  46. font-weight: 200;
  47. color: @navbarBrandColor;
  48. text-shadow: 0 1px 0 @navbarBackgroundHighlight;
  49. &:hover {
  50. text-decoration: none;
  51. }
  52. }
  53. // Plain text in topbar
  54. // -------------------------
  55. .navbar-text {
  56. margin-bottom: 0;
  57. line-height: @navbarHeight;
  58. }
  59. // Janky solution for now to account for links outside the .nav
  60. // -------------------------
  61. .navbar-link {
  62. color: @navbarLinkColor;
  63. &:hover {
  64. color: @navbarLinkColorHover;
  65. }
  66. }
  67. // Dividers in navbar
  68. // -------------------------
  69. .navbar .divider-vertical {
  70. height: @navbarHeight;
  71. margin: 0 9px;
  72. border-left: 1px solid @navbarBackground;
  73. border-right: 1px solid @navbarBackgroundHighlight;
  74. }
  75. // Buttons in navbar
  76. // -------------------------
  77. .navbar .btn,
  78. .navbar .btn-group {
  79. .navbarVerticalAlign(30px); // Vertically center in navbar
  80. }
  81. .navbar .btn-group .btn,
  82. .navbar .input-prepend .btn,
  83. .navbar .input-append .btn {
  84. margin-top: 0; // then undo the margin here so we don't accidentally double it
  85. }
  86. // Navbar forms
  87. // -------------------------
  88. .navbar-form {
  89. margin-bottom: 0; // remove default bottom margin
  90. .clearfix();
  91. input,
  92. select,
  93. .radio,
  94. .checkbox {
  95. .navbarVerticalAlign(30px); // Vertically center in navbar
  96. }
  97. input,
  98. select,
  99. .btn {
  100. display: inline-block;
  101. margin-bottom: 0;
  102. }
  103. input[type="image"],
  104. input[type="checkbox"],
  105. input[type="radio"] {
  106. margin-top: 3px;
  107. }
  108. .input-append,
  109. .input-prepend {
  110. margin-top: 6px;
  111. white-space: nowrap; // preven two items from separating within a .navbar-form that has .pull-left
  112. input {
  113. margin-top: 0; // remove the margin on top since it's on the parent
  114. }
  115. }
  116. }
  117. // Navbar search
  118. // -------------------------
  119. .navbar-search {
  120. position: relative;
  121. float: left;
  122. .navbarVerticalAlign(30px); // Vertically center in navbar
  123. margin-bottom: 0;
  124. .search-query {
  125. margin-bottom: 0;
  126. padding: 4px 14px;
  127. #font > .sans-serif(13px, normal, 1);
  128. .border-radius(15px); // redeclare because of specificity of the type attribute
  129. }
  130. }
  131. // Static navbar
  132. // -------------------------
  133. .navbar-static-top {
  134. position: static;
  135. width: 100%;
  136. margin-bottom: 0; // remove 18px margin for default navbar
  137. .navbar-inner {
  138. .border-radius(0);
  139. }
  140. }
  141. // Fixed navbar
  142. // -------------------------
  143. // Shared (top/bottom) styles
  144. .navbar-fixed-top,
  145. .navbar-fixed-bottom {
  146. position: fixed;
  147. right: 0;
  148. left: 0;
  149. z-index: @zindexFixedNavbar;
  150. margin-bottom: 0; // remove 18px margin for default navbar
  151. }
  152. .navbar-fixed-top .navbar-inner,
  153. .navbar-static-top .navbar-inner {
  154. border-width: 0 0 1px;
  155. }
  156. .navbar-fixed-bottom .navbar-inner {
  157. border-width: 1px 0 0;
  158. }
  159. .navbar-fixed-top .navbar-inner,
  160. .navbar-fixed-bottom .navbar-inner {
  161. padding-left: 0;
  162. padding-right: 0;
  163. .border-radius(0);
  164. }
  165. // Reset container width
  166. // Required here as we reset the width earlier on and the grid mixins don't override early enough
  167. .navbar-static-top .container,
  168. .navbar-fixed-top .container,
  169. .navbar-fixed-bottom .container {
  170. #grid > .core > .span(@gridColumns);
  171. }
  172. // Fixed to top
  173. .navbar-fixed-top {
  174. top: 0;
  175. }
  176. .navbar-fixed-top,
  177. .navbar-static-top {
  178. .navbar-inner {
  179. .box-shadow(inset 0 -1px 0 rgba(0,0,0,.1), 0 1px 10px rgba(0,0,0,.1));
  180. }
  181. }
  182. // Fixed to bottom
  183. .navbar-fixed-bottom {
  184. bottom: 0;
  185. .navbar-inner {
  186. .box-shadow(inset 0 1px 0 rgba(0,0,0,.1), 0 -1px 10px rgba(0,0,0,.1));
  187. }
  188. }
  189. // NAVIGATION
  190. // ----------
  191. .navbar .nav {
  192. position: relative;
  193. left: 0;
  194. display: block;
  195. float: left;
  196. margin: 0 10px 0 0;
  197. }
  198. .navbar .nav.pull-right {
  199. float: right; // redeclare due to specificity
  200. margin-right: 0; // remove margin on float right nav
  201. }
  202. .navbar .nav > li {
  203. float: left;
  204. }
  205. // Links
  206. .navbar .nav > li > a {
  207. float: none;
  208. // Vertically center the text given @navbarHeight
  209. padding: ((@navbarHeight - @baseLineHeight) / 2) 15px ((@navbarHeight - @baseLineHeight) / 2);
  210. color: @navbarLinkColor;
  211. text-decoration: none;
  212. text-shadow: 0 1px 0 @navbarBackgroundHighlight;
  213. }
  214. .navbar .nav .dropdown-toggle .caret {
  215. margin-top: 8px;
  216. }
  217. // Hover
  218. .navbar .nav > li > a:focus,
  219. .navbar .nav > li > a:hover {
  220. background-color: @navbarLinkBackgroundHover; // "transparent" is default to differentiate :hover from .active
  221. color: @navbarLinkColorHover;
  222. text-decoration: none;
  223. }
  224. // Active nav items
  225. .navbar .nav > .active > a,
  226. .navbar .nav > .active > a:hover,
  227. .navbar .nav > .active > a:focus {
  228. color: @navbarLinkColorActive;
  229. text-decoration: none;
  230. background-color: @navbarLinkBackgroundActive;
  231. .box-shadow(inset 0 3px 8px rgba(0,0,0,.125));
  232. }
  233. // Navbar button for toggling navbar items in responsive layouts
  234. // These definitions need to come after '.navbar .btn'
  235. .navbar .btn-navbar {
  236. display: none;
  237. float: right;
  238. padding: 7px 10px;
  239. margin-left: 5px;
  240. margin-right: 5px;
  241. .buttonBackground(darken(@navbarBackgroundHighlight, 5%), darken(@navbarBackground, 5%));
  242. .box-shadow(inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.075));
  243. }
  244. .navbar .btn-navbar .icon-bar {
  245. display: block;
  246. width: 18px;
  247. height: 2px;
  248. background-color: #f5f5f5;
  249. .border-radius(1px);
  250. .box-shadow(0 1px 0 rgba(0,0,0,.25));
  251. }
  252. .btn-navbar .icon-bar + .icon-bar {
  253. margin-top: 3px;
  254. }
  255. // Dropdown menus
  256. // --------------
  257. // Menu position and menu carets
  258. .navbar .nav > li > .dropdown-menu {
  259. &:before {
  260. content: '';
  261. display: inline-block;
  262. border-left: 7px solid transparent;
  263. border-right: 7px solid transparent;
  264. border-bottom: 7px solid #ccc;
  265. border-bottom-color: @dropdownBorder;
  266. position: absolute;
  267. top: -7px;
  268. left: 9px;
  269. }
  270. &:after {
  271. content: '';
  272. display: inline-block;
  273. border-left: 6px solid transparent;
  274. border-right: 6px solid transparent;
  275. border-bottom: 6px solid @dropdownBackground;
  276. position: absolute;
  277. top: -6px;
  278. left: 10px;
  279. }
  280. }
  281. // Menu position and menu caret support for dropups via extra dropup class
  282. .navbar-fixed-bottom .nav > li > .dropdown-menu {
  283. &:before {
  284. border-top: 7px solid #ccc;
  285. border-top-color: @dropdownBorder;
  286. border-bottom: 0;
  287. bottom: -7px;
  288. top: auto;
  289. }
  290. &:after {
  291. border-top: 6px solid @dropdownBackground;
  292. border-bottom: 0;
  293. bottom: -6px;
  294. top: auto;
  295. }
  296. }
  297. // Remove background color from open dropdown
  298. .navbar .nav li.dropdown.open > .dropdown-toggle,
  299. .navbar .nav li.dropdown.active > .dropdown-toggle,
  300. .navbar .nav li.dropdown.open.active > .dropdown-toggle {
  301. background-color: @navbarLinkBackgroundActive;
  302. color: @navbarLinkColorActive;
  303. }
  304. .navbar .nav li.dropdown > .dropdown-toggle .caret {
  305. border-top-color: @navbarLinkColor;
  306. border-bottom-color: @navbarLinkColor;
  307. }
  308. .navbar .nav li.dropdown.open > .dropdown-toggle .caret,
  309. .navbar .nav li.dropdown.active > .dropdown-toggle .caret,
  310. .navbar .nav li.dropdown.open.active > .dropdown-toggle .caret {
  311. border-top-color: @navbarLinkColorActive;
  312. border-bottom-color: @navbarLinkColorActive;
  313. }
  314. // Right aligned menus need alt position
  315. .navbar .pull-right > li > .dropdown-menu,
  316. .navbar .nav > li > .dropdown-menu.pull-right {
  317. left: auto;
  318. right: 0;
  319. &:before {
  320. left: auto;
  321. right: 12px;
  322. }
  323. &:after {
  324. left: auto;
  325. right: 13px;
  326. }
  327. .dropdown-menu {
  328. left: auto;
  329. right: 100%;
  330. margin-left: 0;
  331. margin-right: -1px;
  332. .border-radius(6px 0 6px 6px);
  333. }
  334. }
  335. // Inverted navbar
  336. // -------------------------
  337. .navbar-inverse {
  338. color: @navbarInverseText;
  339. .navbar-inner {
  340. #gradient > .vertical(@navbarInverseBackgroundHighlight, @navbarInverseBackground);
  341. border-color: @navbarInverseBorder;
  342. }
  343. .brand,
  344. .nav > li > a {
  345. color: @navbarInverseLinkColor;
  346. text-shadow: 0 -1px 0 rgba(0,0,0,.25);
  347. &:hover {
  348. color: @navbarInverseLinkColorHover;
  349. }
  350. }
  351. .nav > li > a:focus,
  352. .nav > li > a:hover {
  353. background-color: @navbarInverseLinkBackgroundHover;
  354. color: @navbarInverseLinkColorHover;
  355. }
  356. .nav .active > a,
  357. .nav .active > a:hover,
  358. .nav .active > a:focus {
  359. color: @navbarInverseLinkColorActive;
  360. background-color: @navbarInverseLinkBackgroundActive;
  361. }
  362. // Inline text links
  363. .navbar-link {
  364. color: @navbarInverseLinkColor;
  365. &:hover {
  366. color: @navbarInverseLinkColorHover;
  367. }
  368. }
  369. // Dividers in navbar
  370. .divider-vertical {
  371. border-left-color: @navbarInverseBackground;
  372. border-right-color: @navbarInverseBackgroundHighlight;
  373. }
  374. // Dropdowns
  375. .nav li.dropdown.open > .dropdown-toggle,
  376. .nav li.dropdown.active > .dropdown-toggle,
  377. .nav li.dropdown.open.active > .dropdown-toggle {
  378. background-color: @navbarInverseLinkBackgroundActive;
  379. color: @navbarInverseLinkColorActive;
  380. }
  381. .nav li.dropdown > .dropdown-toggle .caret {
  382. border-top-color: @navbarInverseLinkColor;
  383. border-bottom-color: @navbarInverseLinkColor;
  384. }
  385. .nav li.dropdown.open > .dropdown-toggle .caret,
  386. .nav li.dropdown.active > .dropdown-toggle .caret,
  387. .nav li.dropdown.open.active > .dropdown-toggle .caret {
  388. border-top-color: @navbarInverseLinkColorActive;
  389. border-bottom-color: @navbarInverseLinkColorActive;
  390. }
  391. // Navbar search
  392. .navbar-search {
  393. .search-query {
  394. color: @white;
  395. background-color: @navbarInverseSearchBackground;
  396. border-color: @navbarInverseSearchBorder;
  397. .box-shadow(inset 0 1px 2px rgba(0,0,0,.1), 0 1px 0 rgba(255,255,255,.15));
  398. .transition(none);
  399. .placeholder(@navbarInverseSearchPlaceholderColor);
  400. // Focus states (we use .focused since IE7-8 and down doesn't support :focus)
  401. &:focus,
  402. &.focused {
  403. padding: 5px 15px;
  404. color: @grayDark;
  405. text-shadow: 0 1px 0 @white;
  406. background-color: @navbarInverseSearchBackgroundFocus;
  407. border: 0;
  408. .box-shadow(0 0 3px rgba(0,0,0,.15));
  409. outline: 0;
  410. }
  411. }
  412. }
  413. // Navbar collapse button
  414. .btn-navbar {
  415. .buttonBackground(darken(@navbarInverseBackgroundHighlight, 5%), darken(@navbarInverseBackground, 5%));
  416. }
  417. }