Css 玉石夯上的背景图像
我使用的是node js(没有express),背景图像url有问题Css 玉石夯上的背景图像,css,node.js,pug,Css,Node.js,Pug,我使用的是node js(没有express),背景图像url有问题 .玉锉 extends ../node_modules/pug-bootstrap/_bootstrap block body style include style.css style.css文件: body{ background: #222 url('skyscrapers.jpg') center center no-repeat; background-size: cover;
.玉锉
extends ../node_modules/pug-bootstrap/_bootstrap
block body
style
include style.css
style.css文件:
body{
background: #222 url('skyscrapers.jpg') center center no-repeat;
background-size: cover;
color: white;
height: 100%;
text-align: center;
align-items: center;
}
看起来背景色可以工作,但img没有加载。
我在简单的HTML文件中检查它,一切正常。
img的位置正确。图像将相对于生成的HTML文件加载。确保
摩天大楼.jpg
文件与生成的HTML输出位于同一文件夹中。如果将背景
拆分为背景色
,-图像
,-位置
,会发生什么情况,和-重复
?尝试一下..仍然不起作用。它与.pug文件和HTML文件位于同一个文件中。如何加载生成的HTML?您是否将pug编译成文件并保存在同一文件夹中?我使用writeHead()
函数如下var html=pug.renderFile('views/index.pug');res.writeHead(200,{'Content-Type':'text/html'});res.write(html);res.end()代码>这根本不应该起作用。浏览器中没有文件系统,因此无法执行pug.renderFile
。我建议使用pug cli提前使用node.js呈现文件,然后直接提供生成的HTML。