fix: custom background position on mobile

This commit is contained in:
hamster1963 2024-12-18 11:15:49 +08:00
parent 115fd59ec8
commit 45dc3f7935

View File

@ -46,18 +46,19 @@ const App: React.FC = () => {
return ( return (
<Router basename={import.meta.env.BASE_URL}> <Router basename={import.meta.env.BASE_URL}>
{/* 固定定位的背景层 */}
{customBackgroundImage && (
<div
className="fixed inset-0 z-0 bg-cover min-h-lvh bg-no-repeat bg-center"
style={{ backgroundImage: `url(${customBackgroundImage})` }}
/>
)}
<div <div
className={cn( className={cn("flex min-h-screen w-full flex-col", {
"flex min-h-screen w-full flex-col bg-cover bg-no-repeat bg-center bg-fixed", "bg-background": !customBackgroundImage,
{ })}
"bg-background": !customBackgroundImage,
},
)}
style={{
backgroundImage: customBackgroundImage ? `url(${customBackgroundImage})` : undefined,
}}
> >
<main className="flex min-h-[calc(100vh-calc(var(--spacing)*16))] flex-1 flex-col gap-4 p-4 md:p-10 md:pt-8"> <main className="flex z-20 min-h-[calc(100vh-calc(var(--spacing)*16))] flex-1 flex-col gap-4 p-4 md:p-10 md:pt-8">
<Header /> <Header />
<Routes> <Routes>
<Route path="/" element={<Server />} /> <Route path="/" element={<Server />} />