css样式在ssl上消失 [英] css styles disappear over ssl

查看:281
本文介绍了css样式在ssl上消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过SSL连接时,特定样式将从样式表中删除。我无法想象它的任何押韵或理由,但它是相同的风格,一直下降。也许值得注意的是,用display来隐藏的元素:none;是可见的。列表样式也会恢复为默认浏览器设置,并且还会删除一些背景图像(并非所有图像)。所有URI路径都是相对的 - 来自页面头部以及样式表本身。

When connected over SSL particular styles are getting dropped from the stylesheet. I can't figure any rhyme or reason to it but it's the same styles that are consistently dropped. Perhaps notably, elements that were to be hidden with display:none; are visible. List styles also revert to default browser settings and a couple background images (not all of them) get dropped as well. All URI paths are relative -- both from the page head as well as from the stylesheets themselves.

例如,以下工作...

For example, the following works...

body { background: url(../images/bg-yellowstripes.jpg) repeat 0 0; }

然而,下一行不...

However, the next line does not...

#masthead { background: url(../images/bg-header.jpg) repeat-x 0 100%; }

任何人都有这方面的经验,可以帮助页面正确显示并避免IE混合内容警告?只影响Internet Explorer btw。 Firefox,Safari,Chrome都正常呈现页面,没有任何SSL警告。

Anyone have any experience with this that could help the page display properly and avoid the IE mixed content warning? Only affect Internet Explorer btw. Firefox, Safari, Chrome all render the page normally, without any SSL warnings.

推荐答案

听起来你正在加载你的CSS具有绝对路径的文件。例如,如果您的网站将通过HTTP和HTTPS提供,则应使用相对路径。

It sounds like you're loading your CSS files with absolute paths. For example, if you have a site that is going to be served over HTTP and HTTPS, you should use a relative path instead.

绝对:(不要这样做,IE通过SSL查看会给出安全警告)

Absolute: (Don't do this, IE will give security warnings when viewed over SSL)

<link rel="stylesheet" href="http://mydomain.com/css/style.css" />

相对:

<link rel="stylesheet" href="/css/style.css" />

如果样式来自其他域(例如CDN),请使用双斜杠而不是指定协议。这将导致路径在发出CSS请求时继承请求页面的协议。

If the style is coming from another domain (such as a CDN), use double slashes instead of specifying the protocol. This will cause the path to inherit the protocol the page was requested with when making the CSS request.

<link rel="stylesheet" href="//otherdomain.com/css/style.css" />

此外,使用IE开发人员工具。他们会准确地告诉您从哪个网页上下载SSL的网络资源。

Also, use the IE developer tools. They will tell you exactly what network resources are being loaded from the page under which SSL and not.

这篇关于css样式在ssl上消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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