gpt4 book ai didi

css - 当页面大小小于 VH 时,Tailwind CSS 如何使页脚停留在底部

转载 作者:行者123 更新时间:2023-12-02 01:27:40 27 4
gpt4 key购买 nike

我这里有一个简单的文件。当页面尺寸小于屏幕尺寸时,我希望页脚留在底部。

始终不粘在底部。它必须是最后一件事。如果内容小于屏幕高度,则它必须留在屏幕底部。

我尝试添加 min-h-screen<main> .但它会产生大量空间并将页脚推离屏幕。

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Primary Meta Tags -->
<title>ABC Blog</title>
<script src="https://cdn.tailwindcss.com"></script>

<body style="background-color:#f8f7f3;">

<header class="bg-white px-2 sm:px-4 py-2.5 fixed w-full z-20 top-0 left-0 border-b border-gray-200">
<div class="container flex flex-wrap justify-between items-center mx-auto">
<a href="#" class="flex items-center">
<span class="self-center text-2xl font-semibold whitespace-nowrap">ABC</span>
</a>
</div>
</header>

<main>

<div class="container mx-auto px-5 md:max-w-screen-lg mt-20 md:mt-36">

<div class="p-6 text-center mb-10 md:mb-20">
<h1 class="text-3xl">Blog - Articles, Insights, Tips and Tools</h1>
</div>

<a href="#/shopify-dawn-theme-hidedisable-add-to-cart-popup">
<div class="px-6 py-3 border-2 border-white rounded-lg space-y-2 hover:shadow mt-2">
<h2 class="text-xl font-medium">Lorem ipsum dolor sit amet.</h2>
<p class="py-3 md:py-0 text-gray-500">Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur at viverra justo. In ut tellus laoreet, iaculis velit in, imperdiet.
</p>
<div class="flex space-x-2 text-xs">
<p class="text-gray-500">Oct 13, 2022</p>
<p>|</p>
<p>John</p>
</div>
</div>
</a>
</div>
</main>

<footer class="w-full p-4 bg-white shadow md:flex md:items-center md:justify-between md:p-6 mt-20">
<span class="text-sm sm:text-center">© 2022 <a href="#" class="hover:underline">ABC</a>.
All Rights Reserved.
</span>
</footer>

</body>

</html>

最佳答案

你应该让主体成为一个 flex 容器(列方向)并且页脚总是最后出现。检查此链接,您会找到一个解释清楚的答案: here

关于css - 当页面大小小于 VH 时,Tailwind CSS 如何使页脚停留在底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74078603/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com