Bootstrap css position: fixed
时间: 2023-07-12 10:06:58 浏览: 86
bootstrap 固定文本框
Bootstrap's `position: fixed` CSS property is used to position an element relative to the browser window, regardless of scrolling.
Here's an example of how to use it in Bootstrap:
```html
<div class="fixed-top">This element is fixed to the top of the screen.</div>
```
In this example, the `fixed-top` class is used to apply the `position: fixed` property to the `div` element. This will make it stay at the top of the screen even if the user scrolls down.
You can also use the `fixed-bottom` class to position the element at the bottom of the screen, and the `fixed-left` and `fixed-right` classes to position it to the left or right side of the screen, respectively.
```html
<div class="fixed-bottom">This element is fixed to the bottom of the screen.</div>
<div class="fixed-left">This element is fixed to the left side of the screen.</div>
<div class="fixed-right">This element is fixed to the right side of the screen.</div>
```
Keep in mind that using `position: fixed` can cause some accessibility issues for users with screen readers, so it's important to use it sparingly and with care.
阅读全文