CSS 在 Chrome 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17867746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS not working in Chrome
提问by Phorden
The CSS is not loading for this page of the website I am working on: http://www.thesanfordcenter.net/sanford-center. It happens only in Chrome, but is not a caching issue as the same problem is happening in Chrome on another computer and I have cleared all browsing and cache history in my browser.
我正在处理的网站的这个页面没有加载 CSS:http: //www.thesanfordcenter.net/sanford-center。它只发生在 Chrome 中,但不是缓存问题,因为在另一台计算机上的 Chrome 中也发生了同样的问题,我已经清除了浏览器中的所有浏览和缓存历史记录。
It does seem to be working correctly in FF and IE. The sub pages on this site, which use a different template seem to be working fine.
它似乎在 FF 和 IE 中正常工作。此站点上使用不同模板的子页面似乎工作正常。
I am not sure what it is that is causing this. Any help would be appreciated.
我不确定是什么导致了这种情况。任何帮助,将不胜感激。
采纳答案by lwitzel
Comparing css links between the page you referenced and sub-pages, you have a "media" attribute in your link:
比较您引用的页面和子页面之间的 css 链接,您的链接中有一个“媒体”属性:
Problem:
问题:
<link href="/stylesheets/css_Sanford.css" rel="stylesheet" type="text/css" media="only screen and (min-device-width: 481px" />
Working:
在职的:
<link href="/stylesheets/css_Sanford.css" rel="stylesheet" type="text/css" />
Try removing the "media" attribute and it should work fine.
尝试删除“媒体”属性,它应该可以正常工作。
More specifically, it does not appear that "only" is a valid operating for the media attribute. See this W3Schools pagefor details.
更具体地说,“仅”似乎不是对媒体属性的有效操作。有关详细信息,请参阅此 W3Schools 页面。
回答by Shyam
In Google Chrome
在谷歌浏览器中
>> goto settings
>> search for cache
>> clear browsing data
>> check cached images and files (the past hour / day)
>> clear browsing data
and goto your webpage and press "Ctrl + r"
并转到您的网页并按“Ctrl + r”
Hope this solves your issue Cheers.
希望这能解决您的问题 干杯。
回答by Bluez
Make sure that your CSS and HTM/HTML files use the same encoding !
确保您的 CSS 和 HTM/HTML 文件使用相同的编码!
If your HTM/HTMLfiles are encoded as UNICODE, your stylesheethas to be as well.
如果您的HTM/HTML文件被编码为 UNICODE,那么您的样式表也必须如此。
IE and Edge are not fussy : stylesheets are rendered regardless of the encodings. But Chrome is totally intolerant of unmatched encodings.
IE 和 Edge 并不挑剔:无论编码如何,都会呈现样式表。但是 Chrome 完全不能容忍不匹配的编码。
I tried every solution/suggestion i could find all over the Internet before i noticed, in my text editor, that i was using different encodings. Once I saved the stylesheets with the same encoding used for the web pages, the problem disappeared.
在我在文本编辑器中注意到我使用了不同的编码之前,我尝试了所有可以在 Internet 上找到的解决方案/建议。一旦我使用用于网页的相同编码保存样式表,问题就消失了。
回答by Dave
Just throwing this out there. Was having the same issue with chrome. Css sheet would work in explorer but not in chrome. Led me to believe nothing was wrong with the code.
只是把这个扔在那里。镀铬也有同样的问题。CSS 表可以在资源管理器中工作,但不能在 chrome 中工作。让我相信代码没有问题。
Finally I gave it a closer inspection and found out it was my bad.
最后我仔细检查了它,发现它是我的错。
Wrong herf="file.css"
错误的 herf="file.css"
Correct href="file.css"
正确的 href="file.css"
All ways check your coding LoL.
所有方法都检查您的编码 LoL。
回答by Michal Svrcek
The problem could be caused because the browser can't load files:
问题可能是由于浏览器无法加载文件引起的:
Failed to load resource: the server responded with a status of 404 (Not Found) error in server
回答by seth yount
Check your source where you are calling your code. The 'stylesheets' folder is coded as 'StyleSheets'. Possibly the case-sensitive is messing it up.
检查您在何处调用代码的来源。“样式表”文件夹编码为“样式表”。可能区分大小写将其搞砸了。
I'm thinking maybe since the expstickybar.css file is rendering correctly and it references the 'stylesheets' folder
我在想也许是因为 expstickybar.css 文件正确呈现并且它引用了“样式表”文件夹
回答by Lyn Headley
It doesn't exist:
它不存在:
this is a 404 not found:
这是一个 404 未找到:
http://www.thesanfordcenter.net/CircularContentCarousel/css/demo.css
http://www.thesanfordcenter.net/CircularContentCarousel/css/demo.css
回答by Ryhnn
Are you certain the path is correct? The developer tools in Chrome show the following error.
你确定路径正确吗?Chrome 中的开发人员工具显示以下错误。
Failed to load resource: the server responded with a status of 404 (ERROR: The file requested could not be found.) http://www.thesanfordcenter.net/CircularContentCarousel/css/demo.css
无法加载资源:服务器以 404 状态响应(错误:找不到请求的文件。)http://www.thesanfordcenter.net/CircularContentCarousel/css/demo.css