我如何 link 到服务器生成的带有查询字符串的 CSS 文件?
How do I link to a server generated CSS file with a query string?
我想这样做:
<link href="/style-render?s=base" rel="stylesheet" type="text/css">
当我访问 /style-render?s=base
时,它给了我想要的 CSS,但样式没有被拉入页面。
它适用于 google:
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
所以我知道我可能只是不知道自己做错了什么。
我刚刚弄明白了。
因此,由于我使用的是 CFML,因此我必须使用 cfcontent
标记来指定内容类型,如下所示:
<cfcontent type="text/css; charset=utf-8">
在 php 你会这样做:
<?php
header( 'Content-Type: text/css; charset=UTF-8' );
?>
希望对某人有所帮助!
您需要设置一个content-type
header。很可能它被渲染为 plain/text
而不是 text/css
.
在 PHP 中,您将 header 设置为:
header('Content-Type: text/css');
我想这样做:
<link href="/style-render?s=base" rel="stylesheet" type="text/css">
当我访问 /style-render?s=base
时,它给了我想要的 CSS,但样式没有被拉入页面。
它适用于 google:
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
所以我知道我可能只是不知道自己做错了什么。
我刚刚弄明白了。
因此,由于我使用的是 CFML,因此我必须使用 cfcontent
标记来指定内容类型,如下所示:
<cfcontent type="text/css; charset=utf-8">
在 php 你会这样做:
<?php
header( 'Content-Type: text/css; charset=UTF-8' );
?>
希望对某人有所帮助!
您需要设置一个content-type
header。很可能它被渲染为 plain/text
而不是 text/css
.
在 PHP 中,您将 header 设置为:
header('Content-Type: text/css');