问题
I am using tailwind in my Vuejs app. I have this simple template
<template>
<div class="bg-gray-500 h-screen">
<Header /><!-- //height 32 -->
<div class="w-2/3 mx-auto p-4 text-lg bg-white h-full shadow-lg">
<router-view />
</div>
</div>
</template>
The div with h-screen
is the root or my app. The component<header>
has a tailwind height of h-32
The problem is that the second div causes the page to scroll at the bottom, the height of the <header>
(h-32).
What I want to do
If there is no content, I want the second div to fill the remaining height of the screen but no more. If there is content, I want it grow as necessary.
回答1:
You can leverage .flex
, .flex-col
and .flex-1
for this. Check out docs.
<div class="bg-gray-500 flex flex-col h-screen">
<div class="flex h-32 bg-gray-200"></div>
<div class="flex-1 w-2/3 mx-auto p-4 text-lg bg-white h-full shadow-lg bg-gray-300">
<router-view />
</div>
</div>
来源:https://stackoverflow.com/questions/63412303/how-to-make-div-fill-full-height-of-parent-in-tailwind