简体   繁体   中英

CSS styles are not being applied

I am working on a small web project which was working perfectly fine for some time but suddenly some CSS styles are not being applied anymore.

I have applied styles through a class in HTML.

When I write the same styles inline they are working fine but when applied through a class in HTML, they aren't working.

My question is, why are they working inline but not when I put them in a class and attach a CSS file?

If they are working inline but not when the file is linked I would guess that the link to the css file might have a typo. I had a similar problem earlier and turns out I was linking index.css instead of styles/index.css since I had put the css into its own folder.

First of all check the path of your css file wherever you linked it.

If its not a typo then simply press Ctrl+F5 in chrome (Windows).

Many times when your css file is large so your browser stores it in cache and hence not every time it renders your css file when updated in editor and reloaded the site.

To rectify this simply press Ctrl+F5.

This will clear the browser cache for that tab(that website) and reload the page forcing the browser to render the updated css.

EDIT: For Mac if you are using safari, the shortcut is Command+Alt+E

In Mac if you are using Chrome, Ctrl+F5 will not work, so refer to this site: https://clear-my-cache.com/en/apple-mac-os/google-chrome.html

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