You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_navbar.scss 8.9KB

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