Center Content
Answered
Barbary Lion posted this in #help-forum
Barbary LionOP
Jo, I'm making my own not-found page, but somehow it doesn't want to center itself in the middle of the screen... I know it would work if I change my layout.tsx, but I don't want to do that because I'll change the whole page.
# not-found.tsx
# layout.tsx
# Preview
https://img.walkaisa.dev/Gw3oyJ3Mh7
# not-found.tsx
function NotFound() {
return (
<main className="bg-red-500 container flex justify-center items-center">
<h1 className="mr-5 pr-6 font-semibold text-xl border-r border-white border-opacity-30 leading-10 align-top inline-block">404</h1>
<h2 className="text-base font-normal leading-10 m-0 p-0">This page could not be found.</h2>
</main>
);
}
export default NotFound;# layout.tsx
export default async function RootLayout({
children
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<head>
<body suppressHydrationWarning={true} className={cn("min-h-screen bg-background font-sans antialiased", fontSans.variable)}>
<Provider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
<div id="top" className="relative flex min-h-screen flex-col">
<HeaderComponent />
<div className="flex-1">{children}</div>
<FooterComponent />
</div>
<TailwindIndicator />
<ScrollTop />
</Provider>
</body>
</head>
</html>
);
}# Preview
https://img.walkaisa.dev/Gw3oyJ3Mh7
Answered by Barbary Lion
Okay, solved it by adding "h-screen" to the main div in the root
7 Replies
Try adding h-screen and mt-auto to the main div. That might work. Also, remove the container className.
@conkyyy Try adding h-screen and mt-auto to the main div. That might work. Also, remove the container className.
Barbary LionOP
Well when I add the h-screen, the site is scrollable and I don't want that.
mt-auto also changes nothing
Try removing flex-1?
@conkyyy Try removing flex-1?
Barbary LionOP
That's the thing, I don't want to change that as this changes the whole website. But even if I remove that, it changes nothing.
Barbary LionOP
Okay, solved it by adding "h-screen" to the main div in the root
Answer
Barbary LionOP
ty all