_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. img.logo {
  59. max-width: 50px;
  60. max-height: 50px;
  61. margin-right: 30px;
  62. }
  63. }
  64. // Navbar nav
  65. //
  66. // Custom navbar navigation (doesn't require `.nav`, but does make use of `.nav-link`).
  67. .navbar-nav {
  68. display: flex;
  69. flex-direction: column; // cannot use `inherit` to get the `.navbar`s value
  70. padding-left: 0;
  71. margin-bottom: 0;
  72. list-style: none;
  73. .nav-link {
  74. padding-right: 0;
  75. padding-left: 0;
  76. }
  77. .dropdown-menu {
  78. position: static;
  79. }
  80. }
  81. // Navbar text
  82. //
  83. //
  84. .navbar-text {
  85. padding-top: $nav-link-padding-y;
  86. padding-bottom: $nav-link-padding-y;
  87. }
  88. // Responsive navbar
  89. //
  90. // Custom styles for responsive collapsing and toggling of navbar contents.
  91. // Powered by the collapse Bootstrap JavaScript plugin.
  92. // When collapsed, prevent the toggleable navbar contents from appearing in
  93. // the default flexbox row orientation. Requires the use of `flex-wrap: wrap`
  94. // on the `.navbar` parent.
  95. .navbar-collapse {
  96. flex-basis: 100%;
  97. flex-grow: 1;
  98. // For always expanded or extra full navbars, ensure content aligns itself
  99. // properly vertically. Can be easily overridden with flex utilities.
  100. align-items: center;
  101. }
  102. // Button for toggling the navbar when in its collapsed state
  103. .navbar-toggler {
  104. padding: $navbar-toggler-padding-y $navbar-toggler-padding-x;
  105. @include font-size($navbar-toggler-font-size);
  106. line-height: 1;
  107. background-color: transparent; // remove default button style
  108. border: $border-width solid transparent; // remove default button style
  109. @include border-radius($navbar-toggler-border-radius);
  110. @include transition($navbar-toggler-transition);
  111. &:hover {
  112. text-decoration: none;
  113. }
  114. &:focus {
  115. text-decoration: none;
  116. outline: 0;
  117. box-shadow: 0 0 0 $navbar-toggler-focus-width;
  118. }
  119. }
  120. // Keep as a separate element so folks can easily override it with another icon
  121. // or image file as needed.
  122. .navbar-toggler-icon {
  123. display: inline-block;
  124. width: 1.5em;
  125. height: 1.5em;
  126. vertical-align: middle;
  127. background-repeat: no-repeat;
  128. background-position: center;
  129. background-size: 100%;
  130. }
  131. .navbar-nav-scroll {
  132. max-height: var(--#{$variable-prefix}scroll-height, 75vh);
  133. overflow-y: auto;
  134. }
  135. // scss-docs-start navbar-expand-loop
  136. // Generate series of `.navbar-expand-*` responsive classes for configuring
  137. // where your navbar collapses.
  138. .navbar-expand {
  139. @each $breakpoint in map-keys($grid-breakpoints) {
  140. $next: breakpoint-next($breakpoint, $grid-breakpoints);
  141. $infix: breakpoint-infix($next, $grid-breakpoints);
  142. // stylelint-disable-next-line scss/selector-no-union-class-name
  143. &#{$infix} {
  144. @include media-breakpoint-up($next) {
  145. flex-wrap: nowrap;
  146. justify-content: flex-start;
  147. .navbar-nav {
  148. flex-direction: row;
  149. .dropdown-menu {
  150. position: absolute;
  151. }
  152. .nav-link {
  153. padding-right: $navbar-nav-link-padding-x;
  154. padding-left: $navbar-nav-link-padding-x;
  155. }
  156. }
  157. .navbar-nav-scroll {
  158. overflow: visible;
  159. }
  160. .navbar-collapse {
  161. display: flex !important; // stylelint-disable-line declaration-no-important
  162. flex-basis: auto;
  163. }
  164. .navbar-toggler {
  165. display: none;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. // scss-docs-end navbar-expand-loop
  172. // Navbar themes
  173. //
  174. // Styles for switching between navbars with light or dark background.
  175. // Dark links against a light background
  176. .navbar-light {
  177. .navbar-brand {
  178. color: $navbar-light-brand-color;
  179. &:hover,
  180. &:focus {
  181. color: $navbar-light-brand-hover-color;
  182. }
  183. }
  184. .navbar-nav {
  185. .nav-link {
  186. color: $navbar-light-color;
  187. &:hover,
  188. &:focus {
  189. color: $navbar-light-hover-color;
  190. }
  191. &.disabled {
  192. color: $navbar-light-disabled-color;
  193. }
  194. }
  195. .show > .nav-link,
  196. .nav-link.active {
  197. color: $navbar-light-active-color;
  198. }
  199. }
  200. .navbar-toggler {
  201. color: $navbar-light-color;
  202. border-color: $navbar-light-toggler-border-color;
  203. }
  204. .navbar-toggler-icon {
  205. background-image: escape-svg($navbar-light-toggler-icon-bg);
  206. }
  207. .navbar-text {
  208. color: $navbar-light-color;
  209. a,
  210. a:hover,
  211. a:focus {
  212. color: $navbar-light-active-color;
  213. }
  214. }
  215. }
  216. // White links against a dark background
  217. .navbar-dark {
  218. .navbar-brand {
  219. color: $navbar-dark-brand-color;
  220. &:hover,
  221. &:focus {
  222. color: $navbar-dark-brand-hover-color;
  223. }
  224. }
  225. .navbar-nav {
  226. .nav-link {
  227. color: $navbar-dark-color;
  228. &:hover,
  229. &:focus {
  230. color: $navbar-dark-hover-color;
  231. }
  232. &.disabled {
  233. color: $navbar-dark-disabled-color;
  234. }
  235. }
  236. .show > .nav-link,
  237. .nav-link.active {
  238. color: $navbar-dark-active-color;
  239. }
  240. }
  241. .navbar-toggler {
  242. color: $navbar-dark-color;
  243. border-color: $navbar-dark-toggler-border-color;
  244. }
  245. .navbar-toggler-icon {
  246. background-image: escape-svg($navbar-dark-toggler-icon-bg);
  247. }
  248. .navbar-text {
  249. color: $navbar-dark-color;
  250. a,
  251. a:hover,
  252. a:focus {
  253. color: $navbar-dark-active-color;
  254. }
  255. }
  256. }