CSS Stylesheet在Express App中没有工作
在我的app.js中 app.use(express.static(`public`));
在我的html中,我得到了 < link rel =`stylesheet` href =`css/styles.css`/>
StyleSheet的CSS都无法正常工作。可以做什么?
我的HTML:
<!DOCTYPE html>
<html lang = `en` dir = `ltr`>
<head>
<meta charset = `utf-8` />
<script src="https://kit.fontawesome.com/51479f1cdc.js" crossorigin="anonymous"></script>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel = `stylesheet` href = `css/styles.css`/>
<title>Starting Files</title>
</head>
<body>
<div class = `container full-height-container`>
<div class = `home-container`>
<i class = `fas fa-key fa-6x`></i>
<h1 class = `display-3 heading`>Secrets</h1>
<p class = `lead`>
Don't keep your secrets, share them anonymously.
</p>
<hr/>
<div class = `button-container`>
<a class = `btn btn-primary btn-lg` href = `/register` role = `button`>Register</a>
<a class = `btn btn-dark btn-lg` href = `/login` role = `button`>Log in</a>
</div>
</div>
</div>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
</body>
</html>
公共文件夹包含一个名为CSS的文件夹。在CSS内部有单个文件样式。css。
In my app.js I haveapp.use(express.static(`public`));
and in my HTML I've got<link rel = `stylesheet` href = `css/styles.css`/>
None of the css from the stylesheet is working. What can be done?
My HTML:
<!DOCTYPE html>
<html lang = `en` dir = `ltr`>
<head>
<meta charset = `utf-8` />
<script src="https://kit.fontawesome.com/51479f1cdc.js" crossorigin="anonymous"></script>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel = `stylesheet` href = `css/styles.css`/>
<title>Starting Files</title>
</head>
<body>
<div class = `container full-height-container`>
<div class = `home-container`>
<i class = `fas fa-key fa-6x`></i>
<h1 class = `display-3 heading`>Secrets</h1>
<p class = `lead`>
Don't keep your secrets, share them anonymously.
</p>
<hr/>
<div class = `button-container`>
<a class = `btn btn-primary btn-lg` href = `/register` role = `button`>Register</a>
<a class = `btn btn-dark btn-lg` href = `/login` role = `button`>Log in</a>
</div>
</div>
</div>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
</body>
</html>
The public folder contains a folder named css. Inside css there is a single file styles.css.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
styles.css由于
&lt; link rel =`stylesheet` href =`css/styles.css./&gt;
而不是报价标记而无法使用。 Backticks在JavaScript中工作,但在HTML中不起作用。The styles.css did not work because of the backticks used in
<link rel = `stylesheet` href = `css/styles.css`/>
instead of quotation marks. Backticks work in JavaScript but do not work in HTML.