[英]How do I link to a server generated CSS file with a query string?
I want to do this: 我想做这个:
<link href="/style-render?s=base" rel="stylesheet" type="text/css">
and when I visit /style-render?s=base
, it gives me the CSS that I want, but the styles are not being pulled into the page. 当我访问
/style-render?s=base
,它为我提供了我想要的CSS,但是样式并未被拉入页面。
It works for google: 它适用于谷歌:
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
So I know it's possible I just don't know what I'm doing wrong. 所以我知道我可能不知道自己在做错什么。
I just figured it out. 我只是想通了。
So since I was using CFML I had to specify the content-type by using a cfcontent
tag like so: 因此,由于我使用的是CFML,因此必须使用
cfcontent
标记来指定内容类型,如下所示:
<cfcontent type="text/css; charset=utf-8">
in php you would do it like this: 在php中,您可以这样做:
<?php
header( 'Content-Type: text/css; charset=UTF-8' );
?>
Hope that helps someone! 希望能对某人有所帮助!
You need to set a content-type
header. 您需要设置一个
content-type
标题。 Odds are it's rendering as plain/text
instead of text/css
. 奇怪的是,它呈现为
plain/text
而不是text/css
。
In PHP you'd set your header with: 在PHP中,您可以通过以下方式设置标头:
header('Content-Type: text/css');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.