CSS does not work when I work on localhost: 8080

4

I am creating a website and I have problems loading the CSS stylesheet in my HTML document when I am working in localhost:8080 and I do not understand why.

The structure of my repertoire is as follows:

.
|-- node_modules
|-- ressources
|   |-- css
|   |   '-- oanstyle.css
|   '-- images
|       |-- img1.jpg
|       |-- img2.jpg
|       '-- etc
|-- app.js
|-- index.html
|-- package-lock.json
'-- package.json

I use app.listen(8080) and I do not load the style sheet or the images I have in the folder. I've tried:

<link rel="stylesheet" type="text/css" href="./ressources/css/oanstyle.css">

I've also tried:

<link rel="stylesheet" type="text/css" href="/ressources/css/oanstyle.css">

Y:

 <link rel="stylesheet" type="text/css" href="http://localhost:8080//ressources/css/oanstyle.css">

For the images I have tried the same. Can someone help me?

    
asked by Guillem Puig comerma 13.04.2018 в 20:55
source

1 answer

1

In order to respond to the concern, it is necessary to review with the following URL:

http://localhost:8080//ressources/css/oanstyle.css

In your browser to know if the style file exists ... depending on whether it does not exist (err 404 not found) or has access problems (err 500 internal server error), you will have to validate the state of the file and the relative routes that I inform you in your html code, changing in your css links the following:

<link rel="stylesheet" type="text/css" href="../ressources/css/oanstyle.css">

The hierarchy of directories on a server scrolls with (../../) if you want to go up two levels of your hierarchy for example and so you are putting in place of your absolute paths to make them relative, when doing this process your call should work normally css in html.

I hope you find it useful, greetings.

    
answered by 13.04.2018 / 21:42
source