CSS在Chrome和IE中的HTTPS网页上无法使用 [英] CSS doesn't work on HTTPS pages in Chrome and IE

查看:139
本文介绍了CSS在Chrome和IE中的HTTPS网页上无法使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上,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>


协议相对网址 - Paul Irish

希望它可以帮助!


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆