Reputation: 305
I need your help. I am trying to set background image for my header. Photo is in the "public" folder. I prescribe the way to my photo in css. But i have a mistake. What i am doing wrong? How to set the background image in React?
Css
.header{
width: 100%;
height: 550px;
background-image: url(./public/one.jpg);
}
Js
import React from "react";
export let Header = () => {
return <header className='header'>
</header>
}
Upvotes: 0
Views: 735
Reputation: 188
seems like you're in the src folder, so you'll need to go to the parent directory in order to get to the public folder, like this: "../public/one.jpg"
instead of "./public/one.jpg"
.
I would recommend to add an asset folder within src, instead of using the public folder.
Upvotes: 1