]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Add sticky bottom utility (#35518)
authorFlorian Lacreuse <florianlacreuse@users.noreply.github.com>
Thu, 16 Dec 2021 08:27:00 +0000 (09:27 +0100)
committerGitHub <noreply@github.com>
Thu, 16 Dec 2021 08:27:00 +0000 (10:27 +0200)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
.bundlewatch.config.json
scss/helpers/_position.scss
site/assets/scss/_component-examples.scss
site/content/docs/5.1/components/navbar.md
site/content/docs/5.1/helpers/position.md

index 87494030073dcaed1c0fb2df239ea45c5045d165..5c04c131f22ae3037c5750043a30d3a92f6cdc13 100644 (file)
@@ -22,7 +22,7 @@
     },
     {
       "path": "./dist/css/bootstrap-utilities.min.css",
-      "maxSize": "6.85 kB"
+      "maxSize": "7 kB"
     },
     {
       "path": "./dist/css/bootstrap.css",
index 31851eb721916cebddabaa2bd0e65b551643ce37..59103d94361779f54d3df4078fa375893ae7f8ed 100644 (file)
@@ -16,7 +16,7 @@
   z-index: $zindex-fixed;
 }
 
-// Responsive sticky top
+// Responsive sticky top and bottom
 @each $breakpoint in map-keys($grid-breakpoints) {
   @include media-breakpoint-up($breakpoint) {
     $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
       top: 0;
       z-index: $zindex-sticky;
     }
+
+    .sticky#{$infix}-bottom {
+      position: sticky;
+      bottom: 0;
+      z-index: $zindex-sticky;
+    }
   }
 }
index 208654ae037f2e189a015efc9cc242d3b2c58ae7..f81a0af188b82b0b18e67eea09b7ecdc442ec132 100644 (file)
     margin: -1rem -1rem 1rem;
   }
 
-  .fixed-bottom {
+  .fixed-bottom,
+  .sticky-bottom {
     position: static;
     margin: 1rem -1rem -1rem;
   }
     .sticky-top {
       margin: -1.5rem -1.5rem 1rem;
     }
-    .fixed-bottom {
+    .fixed-bottom,
+    .sticky-bottom {
       margin: 1rem -1.5rem -1.5rem;
     }
   }
index 8d245d10f982195a3f62b8ee630db2fac24d976f..57754e9b42830865218d117e05cd91ca32035822 100644 (file)
@@ -450,9 +450,9 @@ Use any of the responsive containers to change how wide the content in your navb
 
 ## Placement
 
-Use our [position utilities]({{< docsref "/utilities/position" >}}) to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, or stickied to the top (scrolls with the page until it reaches the top, then stays there). Fixed navbars use `position: fixed`, meaning they're pulled from the normal flow of the DOM and may require custom CSS (e.g., `padding-top` on the `<body>`) to prevent overlap with other elements.
+Use our [position utilities]({{< docsref "/utilities/position" >}}) to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, stickied to the top (scrolls with the page until it reaches the top, then stays there), or stickied to the bottom (scrolls with the page until it reaches the bottom, then stays there).
 
-Also note that **`.sticky-top` uses `position: sticky`, which [isn't fully supported in every browser](https://caniuse.com/css-sticky)**.
+Fixed navbars use `position: fixed`, meaning they're pulled from the normal flow of the DOM and may require custom CSS (e.g., `padding-top` on the `<body>`) to prevent overlap with other elements.
 
 {{< example >}}
 <nav class="navbar navbar-light bg-light">
@@ -486,6 +486,14 @@ Also note that **`.sticky-top` uses `position: sticky`, which [isn't fully suppo
 </nav>
 {{< /example >}}
 
+{{< example >}}
+<nav class="navbar sticky-bottom navbar-light bg-light">
+  <div class="container-fluid">
+    <a class="navbar-brand" href="#">Sticky bottom</a>
+  </div>
+</nav>
+{{< /example >}}
+
 ## Scrolling
 
 Add `.navbar-nav-scroll` to a `.navbar-nav` (or other navbar sub-component) to enable vertical scrolling within the toggleable contents of a collapsed navbar. By default, scrolling kicks in at `75vh` (or 75% of the viewport height), but you can override that with the local CSS custom property `--bs-navbar-height` or custom styles. At larger viewports when the navbar is expanded, content will appear as it does in a default navbar.
index d54c1c79554600c3f5aca2c33149f867a4617a7c..8b333bdfcd85203e2e286a0da10941491694d688 100644 (file)
@@ -24,7 +24,7 @@ Position an element at the bottom of the viewport, from edge to edge. Be sure yo
 
 ## Sticky top
 
-Position an element at the top of the viewport, from edge to edge, but only after you scroll past it. The `.sticky-top` utility uses CSS's `position: sticky`, which isn't fully supported in all browsers.
+Position an element at the top of the viewport, from edge to edge, but only after you scroll past it.
 
 ```html
 <div class="sticky-top">...</div>
@@ -40,3 +40,22 @@ Responsive variations also exist for `.sticky-top` utility.
 <div class="sticky-lg-top">Stick to the top on viewports sized LG (large) or wider</div>
 <div class="sticky-xl-top">Stick to the top on viewports sized XL (extra-large) or wider</div>
 ```
+
+## Sticky bottom
+
+Position an element at the bottom of the viewport, from edge to edge, but only after you scroll past it.
+
+```html
+<div class="sticky-bottom">...</div>
+```
+
+## Responsive sticky bottom
+
+Responsive variations also exist for `.sticky-bottom` utility.
+
+```html
+<div class="sticky-sm-bottom">Stick to the bottom on viewports sized SM (small) or wider</div>
+<div class="sticky-md-bottom">Stick to the bottom on viewports sized MD (medium) or wider</div>
+<div class="sticky-lg-bottom">Stick to the bottom on viewports sized LG (large) or wider</div>
+<div class="sticky-xl-bottom">Stick to the bottom on viewports sized XL (extra-large) or wider</div>
+```