Complete list of reasons why a css file might not be working

后端 未结 19 2126
醉酒成梦
醉酒成梦 2020-12-09 02:20

This problem is making me feel like an absolute noob.

Here is the head of my .html file:




        
相关标签:
19条回答
  • 2020-12-09 02:31

    Copy the css file's url and paste it into your browser. If it doesn't load the file than you know the problem is in the url.

    0 讨论(0)
  • 2020-12-09 02:33

    I had the same problem - I changed my text encoding to UTF-16 on my index file and my css file would show up blank when I'd try to load the page in the browser. I figured out by much trial and error that your html and css files have to have the same encoding! I don't know if this would work for you but it did for me.

    0 讨论(0)
  • 2020-12-09 02:34

    New one for you Guys !

    During my Gulp minification process

    <!-- build:css /css/project-mini.css -->
        <link rel="stylesheet" href="css/main.css"/>
        <link rel="stylesheet" href="css/splash.css"/>
        <link rel="stylesheet" href="css/header.css"/>
        <link rel="stylesheet" href="css/print.css" media="print"/>
    <!-- endbuild -->
    

    Last CSS file was for print and the generated output gave me

        <link rel="stylesheet" href="css/project-mini.css" media="print"/>
    

    So because of media="print" all CSS rules were skipped !

    0 讨论(0)
  • 2020-12-09 02:34
    1. I had the same problem, and I used the UTF-8 coding for both of my files as follows:

      add @charset "UTF-8"; in CSS file and <meta charset="UTF-8"> under <head> tag in HTML file. and it worked for me.

      it makes the same encoding for both the files i.e HTML and CSS.

      You can also do the same for "UTF-16" encoding.

    2. If it is still not working check for the <link type="text/css" rel="stylesheet" href="style.css"/> under <head> tag in HTML File where you should mention type="text/css"

    0 讨论(0)
  • 2020-12-09 02:37
    1. Are you sure the stylesheet is loaded? You can see it using the "Net" tab of Firebug on firefox, or on "Network" tab of the Console of your browser.

    2. (If 1 works) can you have a simple sample style and see whether this is getting applied (and visible in the console)?

    0 讨论(0)
  • 2020-12-09 02:37

    I was facing the same problem, but the reason was the styling in the css is wrapped in an ID that is not exist

    #navi ul{
        color: red;
    }
    

    the #navi selector is nowhere in the HTML because i forgot to add it before writing the CSS. in my case I worked with Less file so I nested it like this

    #navi{
        ul{
           color:red;
       }
    }
    

    I hope this help to re-check when things doesn't work

    0 讨论(0)
提交回复
热议问题