在_Layout.cshtml中,我在标记中定义了以下内容:
@RenderSection("JavaScript", required: false);
整件事看起来像这样:
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
@RenderSection("JavaScript", required: false);
</head>
现在在视图的Index.cshtml中我有:
@section JavaScript
{
<style type="text/css" title="currentStyle">
@@import "table/media/css/demo_page.css";
@@import "table/media/css/demo_table.css";
</style>
}
但是'元素样式不能嵌套在元素样式中'。
不确定为什么会这样,有人有什么想法吗?
答案 0 :(得分:1)
通常,您应将url
与@import
:
@section JavaScript
{
<style type="text/css" title="currentStyle">
@@import url("table/media/css/demo_page.css");
@@import url("table/media/css/demo_table.css");
</style>
}
或将link
标记用于href
:
@section JavaScript
{
<link href="@Url.Content("~/table/media/css/demo_page.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/table/media/css/demo_table.css")" rel="stylesheet" type="text/css" />
}