开发者

How to dynamically change CSS elements to be HTTPS or HTTP

开发者 https://www.devze.com 2023-01-30 05:38 出处:网络
I have CSS with background-image\'s elements that refer to another site. Problem is, that in IE you can\'t have resources if you are in HTTP while they are in HTTPS and vise versa.

I have CSS with background-image's elements that refer to another site. Problem is, that in IE you can't have resources if you are in HTTP while they are in HTTPS and vise versa.

I am using ASP.NET and I want to find a way of letting the CSS know about if it was requested in HT开发者_开发问答TPS or NOT...

And I MUST use absolute... (its on a different site)

Thanks!


Just omit the protocol (http: or https:) in your URLs: //domain/path/image.png will use the same protocol as the current page.


The solution would be if you can use relative url instead of absolute in your CSS file while pointing background images.

The problem will gone.

something like:-

#div
{
  background-image:url(../images/img1.png);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消