简体   繁体   中英

ejs file can't apply style sheet

I'm working on a website and the CSS file seemingly at random stopped being applied to the ejs file I was working on. The links work (in this because I can follow the link in vs code) yet the CSS file won't load.

I've tried changing the paths but to no avail and the CSS file is applied to the ejs file when I run it in sublime but not in vs code. The file tree looks like this:

1 Project
-- 1.1 public
   -- 1.1.1 demos.css
-- 1.2 views
   -- 1.2.1 demos.ejs

EJS (demos.ejs)

<link rel="stylesheet" type="text/css" href="../public/demos.css">

CSS (demos.css)

body { 
    background: url(images/About-bg.png) no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    padding-top: 80px;
}

On the console of inspect element on chrome it says:

Refused to apply style from ' http://localhost:8081/demos/demos.css ' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Idk if anyone else has this type of problem but I fixed it by making a demos folder in the public folder because that where the ejs file is looking for some reason.

Hope this helps someone!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM