刚刚在我的学校启动 Express 服务器模块。我做了一个非常简单的网站只是为了尝试一下,但似乎 css 文件没有被执行(在 chrome 的终端 cl 中检查)。
拒绝应用“http://localhost:3000/public/style.css”中的样式,因为其 MIME 类型(“text/html”)不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查。家:26
获取http://localhost:3000/public/einstein-home.jpg 404(未找到)
const express = require('express');
const app = express();
app.use(express.static('public'));
app.get('/home', (request, response) => {
console.log('dirname', __dirname);
response.sendFile(__dirname + '/views/home.html')
});
app.get('/about', (request, response) => {
console.log('dirname', __dirname);
response.sendFile(__dirname + '/views/about.html')
});
app.get('/works', (request, response) => {
console.log('dirname', __dirname);
response.sendFile(__dirname + '/views/works.html')
});
app.listen(3000, () => {
console.log('Website about Einstein');
});
body {
font-family: Verdana, Geneva, Tahoma, sans-serif;
background-color: #f2f2f2;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
font-style: normal;
font-weight: 200;
}
.container {
width: 90%;
margin-left: auto;
margin-right: auto;
height: 600px;
background-color: #FFFFFF;
}
header {
width: 100%;
height: 8%;
background-color: #52bad5;
border-bottom: 1px solid #2C9AB7;
}
nav {
float: right;
width: 50%;
text-align: right;
margin-right: 25px;
}
header nav ul {
list-style: none;
float: right;
}
nav ul li {
float: left;
color: #FFFFFF;
font-size: 14px;
text-align: left;
margin-right: 25px;
letter-spacing: 2px;
font-weight: bold;
transition: all 0.3s linear;
}
ul li a {
color: #FFFFFF;
text-decoration: none;
}
ul li:hover a {
color: #2C9AB7;
}
.text {
width: 90%;
text-align: justify;
font-weight: lighter;
line-height: 25px;
float: left;
padding-left: 20px;
padding-right: 20px;
color: #A3A3A3;
}
ITMISS
相关分类