I’m trying to make the navbar and footer 1/5 of the height of a wrapper div who should take the height of the whole screen but no matter what h-*
class I use it doesn’t take effect:
import { useEffect } from "react";
import React from "react";
function App() {
useEffect(() => {
console.log("hello world");
}, []);
return (
<div className="flex flex-col w-full h-full">
<div className="bg-gray-300 flex justify-center items-center h-1/5 relative">
<p className="m-auto text-5xl">NavBar</p>
</div>
<div className="h-full"></div>
<footer className="bg-gray-300 flex text-5xl justify-center items-center w-full h-1/5 fixed bottom-0">
<p className="m-auto text-5xl">Footer</p>
</footer>
</div>
);
}
export default App;
https://codesandbox.io/s/react-tailwind-starter-forked-c2uh94?file=/src/App.js
2
Answers
From the Tailwind documentation:
So you’ll need to set a static height on the parent to let
h-full
take into effect.I think you can achieve this goal by using tailwind Grid
you can see docs here for additional details : https://tailwindcss.com/docs/grid-row#spanning-rows