是否可以在头标记中添加多个css,并使用一个http请求一次执行所有css文件?
我知道
@import url('/css/typography.css');
@import url('/css/layout.css');
@import url('/css/color.css');
我们可以做类似的事情或任何其他解决方案来减少http requests
<link rel='stylesheet' href='/css/typography.css,layout.css,color.css'>
答案 0 :(得分:1)
不,但您可以将所有样式表汇集到一张表格中,然后将其导入:
<link rel='stylesheet' href='/css/main.css'>
答案 1 :(得分:0)
捆绑您的CSS文件以进行生产和缩小。
http://www.sitepoint.com/faster-page-loads-bundle-your-css-and-javascript/
答案 2 :(得分:0)
是的,您可以使用ASP.NET MVC捆绑和缩小功能。 你创建一个像这样的包:
bundles.Add(new StyleBundle("~/Content/customcss").Include(
"~/Content/css/typography.css",
"~/Content/css/layout.css",
"~/Content/css/color.css"));
你可以这样渲染(在Razor视图中):
@Styles.Render("~/Content/customcss")
在发布编译模式下,您的包将自动合并和缩小,但您也可以在调试模式下手动设置标志:
BundleTable.EnableOptimizations = true;
请参阅this以供参考。
答案 3 :(得分:0)
是的,你可以吗?使用apache / nginx MODPAGESPEED https://www.modpagespeed.com/
<head>
<link rel="stylesheet" type="text/css" href="styles/yellow.css">
<link rel="stylesheet" type="text/css" href="styles/blue.css">
<link rel="stylesheet" type="text/css" href="styles/big.css">
<link rel="stylesheet" type="text/css" href="styles/bold.css">
</head>
可以成为
<head>
<link rel="stylesheet" type="text/css" href="styles/yellow.css+blue.css+big.css+bold.css.pagespeed.cc.xo4He3_gYf.css">
</head>
免责声明:Apache PageSpeed是由Apache Incubator赞助的由Apache Software Foundation(ASF)进行孵化的一项工作。