1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-11 08:04:59 +02:00

Add .nav-underline modifier class (#33126)

* Add .nav-underline modifier class

* Tweak sizing and spacing, add underline on hover

* Rebuild with Sass and CSS variables

* Document CSS vars

* Bump bundlewatch
This commit is contained in:
Mark Otto
2022-12-28 21:55:54 -08:00
committed by GitHub
parent 97576345b1
commit 7d9aa9d716
4 changed files with 72 additions and 4 deletions

View File

@@ -26,7 +26,7 @@
}, },
{ {
"path": "./dist/css/bootstrap.css", "path": "./dist/css/bootstrap.css",
"maxSize": "31.25 kB" "maxSize": "31.5 kB"
}, },
{ {
"path": "./dist/css/bootstrap.min.css", "path": "./dist/css/bootstrap.min.css",

View File

@@ -28,6 +28,8 @@
font-weight: var(--#{$prefix}nav-link-font-weight); font-weight: var(--#{$prefix}nav-link-font-weight);
color: var(--#{$prefix}nav-link-color); color: var(--#{$prefix}nav-link-color);
text-decoration: if($link-decoration == none, null, none); text-decoration: if($link-decoration == none, null, none);
background: none;
border: 0;
@include transition($nav-link-transition); @include transition($nav-link-transition);
&:hover, &:hover,
@@ -63,7 +65,6 @@
.nav-link { .nav-link {
margin-bottom: calc(-1 * var(--#{$prefix}nav-tabs-border-width)); // stylelint-disable-line function-disallowed-list margin-bottom: calc(-1 * var(--#{$prefix}nav-tabs-border-width)); // stylelint-disable-line function-disallowed-list
background: none;
border: var(--#{$prefix}nav-tabs-border-width) solid transparent; border: var(--#{$prefix}nav-tabs-border-width) solid transparent;
@include border-top-radius(var(--#{$prefix}nav-tabs-border-radius)); @include border-top-radius(var(--#{$prefix}nav-tabs-border-radius));
@@ -110,8 +111,6 @@
// scss-docs-end nav-pills-css-vars // scss-docs-end nav-pills-css-vars
.nav-link { .nav-link {
background: none;
border: 0;
@include border-radius(var(--#{$prefix}nav-pills-border-radius)); @include border-radius(var(--#{$prefix}nav-pills-border-radius));
&:disabled { &:disabled {
@@ -129,6 +128,44 @@
} }
//
// Underline
//
.nav-underline {
// scss-docs-start nav-underline-css-vars
--#{$prefix}nav-underline-gap: #{$nav-underline-gap};
--#{$prefix}nav-underline-border-width: #{$nav-underline-border-width};
--#{$prefix}nav-underline-link-active-color: #{$nav-underline-link-active-color};
// scss-docs-end nav-underline-css-vars
gap: var(--#{$prefix}nav-underline-gap);
// .nav-item + .nav-item,
// .nav-link + .nav-link {
// margin-left: $nav-link-padding-x;
// }
.nav-link {
padding-right: 0;
padding-left: 0;
border-bottom: var(--#{$prefix}nav-underline-border-width) solid transparent;
&:hover,
&:focus {
border-bottom-color: currentcolor;
}
}
.nav-link.active,
.show > .nav-link {
font-weight: $font-weight-bold;
color: var(--#{$prefix}nav-underline-link-active-color);
border-bottom-color: currentcolor;
}
}
// //
// Justified variants // Justified variants
// //

View File

@@ -1136,6 +1136,10 @@ $nav-tabs-link-active-border-color: var(--#{$prefix}border-color) var(--#{$prefi
$nav-pills-border-radius: $border-radius !default; $nav-pills-border-radius: $border-radius !default;
$nav-pills-link-active-color: $component-active-color !default; $nav-pills-link-active-color: $component-active-color !default;
$nav-pills-link-active-bg: $component-active-bg !default; $nav-pills-link-active-bg: $component-active-bg !default;
$nav-underline-gap: 1rem !default;
$nav-underline-border-width: .125rem !default;
$nav-underline-link-active-color: var(--#{$prefix}emphasis-color) !default;
// scss-docs-end nav-variables // scss-docs-end nav-variables

View File

@@ -167,6 +167,27 @@ Take that same HTML, but use `.nav-pills` instead:
</ul> </ul>
{{< /example >}} {{< /example >}}
### Underline
Take that same HTML, but use `.nav-underline` instead:
{{< example >}}
<ul class="nav nav-underline">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{{< /example >}}
### Fill and justify ### Fill and justify
Force your `.nav`'s contents to extend the full available width one of two modifier classes. To proportionately fill all available space with your `.nav-item`s, use `.nav-fill`. Notice that all horizontal space is occupied, but not every nav item has the same width. Force your `.nav`'s contents to extend the full available width one of two modifier classes. To proportionately fill all available space with your `.nav-item`s, use `.nav-fill`. Notice that all horizontal space is occupied, but not every nav item has the same width.
@@ -324,6 +345,12 @@ On the `.nav-pills` modifier class:
{{< scss-docs name="nav-pills-css-vars" file="scss/_nav.scss" >}} {{< scss-docs name="nav-pills-css-vars" file="scss/_nav.scss" >}}
{{< added-in "5.3.0" >}}
On the `.nav-underline` modifier class:
{{< scss-docs name="nav-underline-css-vars" file="scss/_nav.scss" >}}
### Sass variables ### Sass variables
{{< scss-docs name="nav-variables" file="scss/_variables.scss" >}} {{< scss-docs name="nav-variables" file="scss/_variables.scss" >}}