css import from another server

2019-07-21 09:08发布

it is possible to import the css file from another server? let's say i have my html on www.mysite.com can i import my css like this?

<link href="www.anothersite.com/style.css" rel="stylesheet" type="text/css"  />

标签: css import
3条回答
我想做一个坏孩纸
2楼-- · 2019-07-21 09:23

Yes, any full url is valid for css. You'll want to include http:// though.

<link href="http://www.anothersite.com/style.css" rel="stylesheet" type="text/css"  />
查看更多
别忘想泡老子
3楼-- · 2019-07-21 09:23

You'll probably want to start the url with http://, otherwise some browsers will interpret that as http://your.currenturl.com/www.anothersite.com/style.css.

查看更多
再贱就再见
4楼-- · 2019-07-21 09:23

Just to extend the other guys comments, and particularly for those using SSL certificates, you might want to write the href as "//www.anothersite.com/style.css" to avoid issues with an SSL site requesting content from a non SSL site.

Note that you exclude the "http:" or "https:" bit from the URL.

The browser will automatically add either "http:" or "https:".

查看更多
登录 后发表回答