Next.js background-image css property cant load the image
when i used JSX styles then added position absolute property it worked just fine.
Like this:
<style JSX>{`
.team {
width:100%;
height:100%;
position:absolute;
background: url('`+img+`') no-repeat;
}
`}</style>
Background image in stylesheet not loading Nextjs
Images in Next.js in the public
directory can be referred to with public
as the base route, so this should work:
background-image: url('/images/mobile-image-hero-1.jpg');
Setting background image to a div in nextjs not working
The solution was to change the path of the image by removing the public path. It was answered here. Change path to /img instead of /public/image. /public is the actual root of the site in this case.
.page-container-welcome {
height: 100vh;
position: relative;
background-size: cover;
background-image: url("/img/art-thing.jpg");
}
Related Topics
Change the Background Color When an Input Is Checked
Angular 6 Component Not Showing Up
How to Pass Boolean Variable of False in a Url
How to Prevent Autoplay in Iframe HTML Content
How to Force Div Contents to Stay in One Line With HTML and CSS
How to Save User-Entered Line Breaks from a Textarea to a Database
How to Make a Gap Between Two Div Within the Same Column
Using HTML Anchor Link #Id in Angular 6
Setting a Max Character Length in CSS
Making Div Visible or Invisible Depend on Condition
Chrome User Agent Stylesheet Overwriting My Site Style
How to Prevent Newline At the End of HTML Input Field
How to Remove Hover Effect from Bootstrap Button
How to Force Div Contents to Stay in One Line With HTML and CSS
Placing Two Divs on Top of Each Other Without Using Position:Absolute
How to Type Text With Hat "^" in HTML
How to Prevent Flex-Items from Overflowing Flex Parent With No Wrap