admin管理员组

文章数量:1401673

I'm facing an issue with Next.js 14 where my layout breaks on laptops and other devices that have Windows display scaling enabled by default. Some UI elements get misaligned, and the overall layout looks off.

To fix this, I want to force the initial viewport to be set to a standard 100%, ignoring any scaling settings. Here's what I tried:

export const viewport: Viewport = {
    width: 'device-width',
    initialScale: 1,
    maximumScale: 1,
    minimumScale: 1,
    userScalable: false,
};

export default function RootLayout({
    children,
}: Readonly<{
    children: React.ReactNode;
}>) {
    return (
        <html lang='en'>
            <body className={roboto.className}>
                <Navbar menuData={menuData}></Navbar>
                {children}
                <footer>
                    <Footer></Footer>
                </footer>
            </body>
        </html>
    );
}

However, this doesn't seem to have any effect in the browser.

Am I missing something? How can I properly enforce a fixed initial scale to prevent layout issues caused by Windows scaling?

Any help would be greatly appreciated!

本文标签: reactjsNextjs 14 – How to Force Initial Viewport to 100 to Fix Scaling IssuesStack Overflow