1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-22 14:44:21 +00:00

Use background to change image

This commit is contained in:
Steffo 2022-06-03 04:25:26 +02:00
parent b5e1138e57
commit 85cea60e04
Signed by: steffo
GPG key ID: 6965406171929D01
2 changed files with 9 additions and 7 deletions

View file

@ -4,13 +4,13 @@ import { useDefinedContext } from "../utils/definedContext";
export function Postcard() { export function Postcard() {
const [postcard, _] = useDefinedContext(PostcardContext) const [postcard, _] = useDefinedContext(PostcardContext)
const postcardUrl = typeof postcard === "string" ? postcard : postcard.src
/* eslint-disable @next/next/no-img-element */ /* eslint-disable @next/next/no-img-element */
return ( return <>
<img <div
className="postcard" className="postcard"
src={typeof postcard === "string" ? postcard : postcard.src} style={{backgroundImage: `url(${postcardUrl})`}}
alt=""
draggable={false}
/> />
) </>
} }

View file

@ -110,7 +110,9 @@ input.negative, button.negative {
.postcard { .postcard {
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
object-fit: cover;
background-attachment: fixed;
background-size: cover;
position: absolute; position: absolute;
z-index: -1; z-index: -1;