_navbar.scss 6.7 KB

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