CSS在Chrome和IE中的HTTPS网页上无法使用 [英] CSS doesn't work on HTTPS pages in Chrome and IE
问题描述
在我的网站上,Chrome无法加载样式表(如果网页是使用https打开的)。
例如,在页面test.php中, CSS包括:
< link href =http://www.domain.com/css/mainstyle.css =stylesheettype =text / css>
它使用绝对路径,因为有很多SEO,子目录等,所以更容易包括
如果我以 http://www.domain.com/test.php 它工作正常,但如果我打开它作为 https: //www.domain.com/test.php Chrome拒绝载入样式表!
它适用于Firefox和Safari。我可以理解IE是一个特殊需要的浏览器,但为什么Chrome会这样做,我该如何解决呢?
调用CSS文件https://domain.com/css/mainstyle.css 解决了这个问题,但是真的有必要吗?
也许尝试协议相关网址
:
< >
< link href =// www.domain.com/css/mainstyle.css =stylesheettype =text / css>
希望它可以帮助!
On my site, Chrome can't load a stylesheet if the page is opened with https.
For instance, on the page test.php I have the following CSS include:
<link href="http://www.domain.com/css/mainstyle.css" rel="stylesheet" type="text/css">
It uses the absolute path because there's a lot of SEO, subdirectories etc, so it's much easier to include it like this than by looking for relative paths.
If I open the page as http://www.domain.com/test.php it works fine, but if I open it as https://www.domain.com/test.php Chrome refuses to load the stylesheet!
It works in Firefox and Safari. I can understand IE being a 'special needs' browser, but why is Chrome doing this and how can I fix it?
Calling the CSS file with https://domain.com/css/mainstyle.css fixes the issue, but is it really necessary?
Maybe try Protocol Relative URLs
:
< link href="//www.domain.com/css/mainstyle.css" rel="stylesheet" type="text/css" >
The Protocol-relative URL - Paul Irish
Hope it can help!
这篇关于CSS在Chrome和IE中的HTTPS网页上无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!