【发布时间】:2020-09-12 11:46:25
【问题描述】:
我是 nextjs 的新手,我不明白为什么没有为这个 div 设置背景图像。在根目录中,我有一个名为 public 的文件夹,其中包含 art-thing.jpg 文件。styles.css 在根目录中。 index.js 位于根目录的 pages 目录中。我可以将背景设置为颜色,但不能将其设置为图像。有人有类似问题的帖子,但我希望我的 css 不是内联的。
styles.css
html {
scroll-behavior: smooth;
height: 100%;
}
body {
margin: 0px;
padding: 0px;
}
.page-container {
height: 100vh;
position: relative;
}
.page-container-welcome {
height: 100vh;
position: relative;
background-size: cover;
background-image: url("/public/img/Branding/art-thing.jpg");
}
.content-wrap{
padding-bottom: 2.5rem;
}
index.js
import 'bootstrap/dist/css/bootstrap.min.css';
import Head from 'next/head';
import HekateNav from "../client/components/nav";
import Footer from "../client/components/footer";
function Home() {
return (
<div>
<Head>
<title>Hekate</title>
</Head>
<div className="page-container-welcome">
<div className="content-wrap">
<HekateNav/>
</div>
</div>
<Footer/>
</div>
);
};
export default Home
我得到的控制台错误
DevTools failed to load SourceMap: Could not load content for http://localhost:3000/_next/static/css/bootstrap.min.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
【问题讨论】: