_navbar.scss 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. // Contents
  2. //
  3. // Navbar
  4. // Navbar brand
  5. // Navbar nav
  6. // Navbar text
  7. // Navbar divider
  8. // Responsive navbar
  9. // Navbar position
  10. // Navbar themes
  11. // Navbar
  12. //
  13. // Provide a static navbar from which we expand to create full-width, fixed, and
  14. // other navbar variations.
  15. .navbar {
  16. position: relative;
  17. display: flex;
  18. flex-wrap: wrap; // allow us to do the line break for collapsing content
  19. align-items: center;
  20. justify-content: space-between; // space out brand from logo
  21. padding: $navbar-padding-y $navbar-padding-x;
  22. // Because flex properties aren't inherited, we need to redeclare these first
  23. // few properties so that content nested within behave properly.
  24. > .container,
  25. > .container-fluid {
  26. display: flex;
  27. flex-wrap: wrap;
  28. align-items: center;
  29. justify-content: space-between;
  30. }
  31. }
  32. // Navbar brand
  33. //
  34. // Used for brand, project, or site names.
  35. .navbar-brand {
  36. display: inline-block;
  37. padding-top: $navbar-brand-padding-y;
  38. padding-bottom: $navbar-brand-padding-y;
  39. margin-right: $navbar-padding-x;
  40. @include font-size($navbar-brand-font-size);
  41. line-height: inherit;
  42. white-space: nowrap;
  43. @include hover-focus {
  44. text-decoration: none;
  45. }
  46. }
  47. // Navbar nav
  48. //
  49. // Custom navbar navigation (doesn't require `.nav`, but does make use of `.nav-link`).
  50. .navbar-nav {
  51. display: flex;
  52. flex-direction: column; // cannot use `inherit` to get the `.navbar`s value
  53. padding-left: 0;
  54. margin-bottom: 0;
  55. list-style: none;
  56. .nav-link {
  57. padding-right: 0;
  58. padding-left: 0;
  59. }
  60. .dropdown-menu {
  61. position: static;
  62. float: none;
  63. }
  64. }
  65. // Navbar text
  66. //
  67. //
  68. .navbar-text {
  69. display: inline-block;
  70. padding-top: $nav-link-padding-y;
  71. padding-bottom: $nav-link-padding-y;
  72. }
  73. // Responsive navbar
  74. //
  75. // Custom styles for responsive collapsing and toggling of navbar contents.
  76. // Powered by the collapse Bootstrap JavaScript plugin.
  77. // When collapsed, prevent the toggleable navbar contents from appearing in
  78. // the default flexbox row orientation. Requires the use of `flex-wrap: wrap`
  79. // on the `.navbar` parent.
  80. .navbar-collapse {
  81. flex-basis: 100%;
  82. flex-grow: 1;
  83. // For always expanded or extra full navbars, ensure content aligns itself
  84. // properly vertically. Can be easily overridden with flex utilities.
  85. align-items: center;
  86. }
  87. // Button for toggling the navbar when in its collapsed state
  88. .navbar-toggler {
  89. padding: $navbar-toggler-padding-y $navbar-toggler-padding-x;
  90. @include font-size($navbar-toggler-font-size);
  91. line-height: 1;
  92. background-color: transparent; // remove default button style
  93. border: $border-width solid transparent; // remove default button style
  94. @include border-radius($navbar-toggler-border-radius);
  95. @include hover-focus {
  96. text-decoration: none;
  97. }
  98. }
  99. // Keep as a separate element so folks can easily override it with another icon
  100. // or image file as needed.
  101. .navbar-toggler-icon {
  102. display: inline-block;
  103. width: 1.5em;
  104. height: 1.5em;
  105. vertical-align: middle;
  106. content: "";
  107. background: no-repeat center center;
  108. background-size: 100% 100%;
  109. }
  110. // Generate series of `.navbar-expand-*` responsive classes for configuring
  111. // where your navbar collapses.
  112. .navbar-expand {
  113. @each $breakpoint in map-keys($grid-breakpoints) {
  114. $next: breakpoint-next($breakpoint, $grid-breakpoints);
  115. $infix: breakpoint-infix($next, $grid-breakpoints);
  116. &#{$infix} {
  117. @include media-breakpoint-down($breakpoint) {
  118. > .container,
  119. > .container-fluid {
  120. padding-right: 0;
  121. padding-left: 0;
  122. }
  123. }
  124. @include media-breakpoint-up($next) {
  125. flex-flow: row nowrap;
  126. justify-content: flex-start;
  127. .navbar-nav {
  128. flex-direction: row;
  129. .dropdown-menu {
  130. position: absolute;
  131. }
  132. .nav-link {
  133. padding-right: $navbar-nav-link-padding-x;
  134. padding-left: $navbar-nav-link-padding-x;
  135. }
  136. }
  137. // For nesting containers, have to redeclare for alignment purposes
  138. > .container,
  139. > .container-fluid {
  140. flex-wrap: nowrap;
  141. }
  142. .navbar-collapse {
  143. display: flex !important; // stylelint-disable-line declaration-no-important
  144. // Changes flex-bases to auto because of an IE10 bug
  145. flex-basis: auto;
  146. }
  147. .navbar-toggler {
  148. display: none;
  149. }
  150. }
  151. }
  152. }
  153. }
  154. // Navbar themes
  155. //
  156. // Styles for switching between navbars with light or dark background.
  157. // Dark links against a light background
  158. .navbar-light {
  159. .navbar-brand {
  160. color: $navbar-light-brand-color;
  161. @include hover-focus {
  162. color: $navbar-light-brand-hover-color;
  163. }
  164. }
  165. .navbar-nav {
  166. .nav-link {
  167. color: $navbar-light-color;
  168. @include hover-focus {
  169. color: $navbar-light-hover-color;
  170. }
  171. &.disabled {
  172. color: $navbar-light-disabled-color;
  173. }
  174. }
  175. .show > .nav-link,
  176. .active > .nav-link,
  177. .nav-link.show,
  178. .nav-link.active {
  179. color: $navbar-light-active-color;
  180. }
  181. }
  182. .navbar-toggler {
  183. color: $navbar-light-color;
  184. border-color: $navbar-light-toggler-border-color;
  185. }
  186. .navbar-toggler-icon {
  187. background-image: $navbar-light-toggler-icon-bg;
  188. }
  189. .navbar-text {
  190. color: $navbar-light-color;
  191. a {
  192. color: $navbar-light-active-color;
  193. @include hover-focus {
  194. color: $navbar-light-active-color;
  195. }
  196. }
  197. }
  198. }
  199. // White links against a dark background
  200. .navbar-dark {
  201. .navbar-brand {
  202. color: $navbar-dark-brand-color;
  203. @include hover-focus {
  204. color: $navbar-dark-brand-hover-color;
  205. }
  206. }
  207. .navbar-nav {
  208. .nav-link {
  209. color: $navbar-dark-color;
  210. @include hover-focus {
  211. color: $navbar-dark-hover-color;
  212. }
  213. &.disabled {
  214. color: $navbar-dark-disabled-color;
  215. }
  216. }
  217. .show > .nav-link,
  218. .active > .nav-link,
  219. .nav-link.show,
  220. .nav-link.active {
  221. color: $navbar-dark-active-color;
  222. }
  223. }
  224. .navbar-toggler {
  225. color: $navbar-dark-color;
  226. border-color: $navbar-dark-toggler-border-color;
  227. }
  228. .navbar-toggler-icon {
  229. background-image: $navbar-dark-toggler-icon-bg;
  230. }
  231. .navbar-text {
  232. color: $navbar-dark-color;
  233. a {
  234. color: $navbar-dark-active-color;
  235. @include hover-focus {
  236. color: $navbar-dark-active-color;
  237. }
  238. }
  239. }
  240. }