使用 TailwindCSS 将元素的高度扩展到页面底部
Expand an element's height to the bottom of the page with TailwindCSS
如何将第三个元素展开到页面底部?我测试了很多 h-full
但是元素的高度变成了屏幕的高度所以右边有一个滚动条并且对象太高了。我只希望它适合页面的其余部分。
html, body {
height: 100%;
}
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<div class="text-gray">
<nav class="fixed flex shadow-md w-full bg-blue-700 p-3">
<div>
<span class="text-xl">Navbar</span>
</div>
</nav>
<div class="pt-16 px-2">
<div class="bg-orange-200">object1</div>
<div class="bg-red-200">object2</div>
<div class="bg-blue-200">object3</div>
</div>
</div>
您可以尝试如下:
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<div class="text-gray">
<nav class="fixed flex shadow-md w-full bg-blue-700 p-3">
<div>
<span class="text-xl">Navbar</span>
</div>
</nav>
<div class="pt-16 px-2 h-screen flex flex-col"> <!-- 3 classes here -->
<div class="bg-orange-200">object1</div>
<div class="bg-red-200">object2</div>
<div class="bg-blue-200 flex-grow">object3</div> <!-- 1 classe here -->
</div>
</div>
如何将第三个元素展开到页面底部?我测试了很多 h-full
但是元素的高度变成了屏幕的高度所以右边有一个滚动条并且对象太高了。我只希望它适合页面的其余部分。
html, body {
height: 100%;
}
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<div class="text-gray">
<nav class="fixed flex shadow-md w-full bg-blue-700 p-3">
<div>
<span class="text-xl">Navbar</span>
</div>
</nav>
<div class="pt-16 px-2">
<div class="bg-orange-200">object1</div>
<div class="bg-red-200">object2</div>
<div class="bg-blue-200">object3</div>
</div>
</div>
您可以尝试如下:
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<div class="text-gray">
<nav class="fixed flex shadow-md w-full bg-blue-700 p-3">
<div>
<span class="text-xl">Navbar</span>
</div>
</nav>
<div class="pt-16 px-2 h-screen flex flex-col"> <!-- 3 classes here -->
<div class="bg-orange-200">object1</div>
<div class="bg-red-200">object2</div>
<div class="bg-blue-200 flex-grow">object3</div> <!-- 1 classe here -->
</div>
</div>