[英]Linking CSS stylesheet serves wrong file
I have a weird/frustrating problem. 我有一个奇怪/令人沮丧的问题。 I'm trying to link my CSS stylesheet to my HTML and when I check in the Chrome dev tools what the file looks like live (rather, why my styling isn't working), I'm getting an entirely different file showing as my .css file.
我正在尝试将CSS样式表链接到HTML,当我检查Chrome开发工具时,该文件看起来像是实时的(而是为什么我的样式不起作用),我得到的是一个完全不同的文件.css文件。
Here's my file directory: 这是我的文件目录:
- app
- public
- file1.html
- file2.html
- assets
- style
- reset.css
- style.css
And here's the head of file1.html: 这是file1.html的标题:
<script src="https://code.jquery.com/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="../../assets/style/reset.css" />
<link rel="stylesheet" href="https://unpkg.com/purecss@0.6.2/build/pure-min.css" integrity="blahblahblah" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/purecss@0.6.2/build/grids-responsive-min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../../assets/style/style.css">
The last line is my relative path. 最后一行是我的相对路径。
The contents of file2.html are showing up as the contents of style.css when I look at it through dev tools, but all that really is in style.css is some styling for the h1 element. 当我通过开发工具查看时,file2.html的内容显示为style.css的内容,但style.css的全部内容仅是h1元素的样式。 Am I just being a dummy with the relative file path for the CSS file?
我只是作为具有CSS文件相对文件路径的虚拟对象吗? I thought maybe the other CSS stylesheets were impeding this style sheet, but commenting them out still results in the contents of file2.html as my css file.
我以为其他CSS样式表可能会阻止此样式表,但是将它们注释掉仍会导致file2.html的内容作为我的CSS文件。 What am I missing?
我想念什么?
您的路径似乎是正确的,但这可能是因为您缺少完整性属性的右引号。
So this is within an express app and I hadn't served up my public folder so that it could use it to access static files. 因此,这是在Express应用程序内,并且我没有提供我的公用文件夹,因此它可以使用它来访问静态文件。
Needed this: 需要这个:
app.use(express.static(path.join(__dirname, '../public')));
您的第三个链接在blahblahblah之后缺少“。请尝试解决该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.