跳到主要内容
输入关键词开始搜索,↑ ↓ 选择,Enter 打开
没有找到匹配的文档

定位

使用这些辅助工具可以快速配置元素的位置。

类名描述
.fixed-top将元素固定到视口顶部。
.fixed-bottom将元素固定到视口底部。
.sticky{-$infix}-top响应式地将元素固定到视口顶部。
.sticky{-$infix}-bottom响应式地将元素固定到视口底部。

固定顶部

将元素定位在视口顶部,从一边到另一边。确保你理解在项目中使用固定定位的影响;你可能需要添加额外的 CSS。

HTML
          <div class="fixed-top">...</div>
        

固定底部

将元素定位在视口底部,从边到边。确保你了解固定定位在你的项目中的影响;你可能需要添加额外的 CSS。

HTML
          <div class="fixed-bottom">...</div>
        

固定顶部

将元素定位在视口顶部,从边缘到边缘,但仅在你滚动过它之后。

HTML
          <div class="sticky-top">...</div>
        

响应式粘性顶部

针对.sticky-top效用也存在响应式变体。

HTML
          <div class="sm:sticky-top">Stick to the top on viewports sized SM (small) or wider</div>
<div class="md:sticky-top">Stick to the top on viewports sized MD (medium) or wider</div>
<div class="lg:sticky-top">Stick to the top on viewports sized LG (large) or wider</div>
<div class="xl:sticky-top">Stick to the top on viewports sized XL (extra-large) or wider</div>
<div class="2xl:sticky-top">Stick to the top on viewports sized 2XL (extra-extra-large) or wider</div>
        

固定底部

将元素定位在视口底部,从边到边,但只有在滚动超过它之后才会这样。

HTML
          <div class="sticky-bottom">...</div>
        

响应式粘性底部

针对.sticky-bottom效用也存在响应式变体。

HTML
          <div class="sm:sticky-bottom">Stick to the bottom on viewports sized SM (small) or wider</div>
<div class="md:sticky-bottom">Stick to the bottom on viewports sized MD (medium) or wider</div>
<div class="lg:sticky-bottom">Stick to the bottom on viewports sized LG (large) or wider</div>
<div class="xl:sticky-bottom">Stick to the bottom on viewports sized XL (extra-large) or wider</div>
<div class="2xl:sticky-bottom">Stick to the bottom on viewports sized 2XL (extra-extra-large) or wider</div>