【Tailwind CSS】当页面内容过少,怎样让footer保持在屏幕底部?

本文介绍了如何在使用TailwindCSS时,通过flex属性使footer始终保持在屏幕底部,即使页面内容较少。通过包裹页面内容的
标签和设置footer的`mt-auto`类名,可以优雅地解决footer尴尬的位置问题。
摘要由CSDN通过智能技术生成

footer通常写版权信息等,显示在页面底部。如果页面内容过少,则footer会出现在屏幕中间位置,很尴尬。在 Tailwind 中,你可以使用flex来实现footer保持在屏幕或页面底部。

代码:

<div class="flex flex-col min-h-screen">
  <slot />

  <footer class="footer footer-center p-4 bg-base-300 text-base-content mt-auto">
    <aside>
      <p>Copyright © 2023 - All right reserved by airoom.chat</p>
    </aside>
  </footer>
</div>

用flex包裹全部页面内容,footer设置类名:mt-auto 即可。

参考:playground

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值