Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a background image with svelte?

How can I set a background image with svelte?

The code is here for reference: Svelte sandbox

like image 892
Monk_buzz Avatar asked Nov 06 '25 07:11

Monk_buzz


1 Answers

You got it right. We probably can't use static assets on the REPL but what you did works well with any image from the web:

From your style section in Todos.svelte:

    :global(body){
        background-color: lightseagreen;
        background-image: url("https://images.pexels.com/photos/956981/milky-way-starry-sky-night-sky-star-956981.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260");
    }
like image 69
Andreas Dolk Avatar answered Nov 08 '25 19:11

Andreas Dolk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!