MVC3引用了Layout页的View,怎么加自己的css
1个回答
展开全部
View文件夹下面会有个_ViewStart.cshtml的文件,初始化了你的模板。如果不使用模板Layout = null
View Code
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
添加css可以按楼上说的
通常我会把CSS |RenderSection加在头,js加在末尾
View Code
复制代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
@RenderSection("Meta",false)
<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("Css",false)
</head>
<body>
@RenderBody()
@RenderSection("Js",false)
</body>
</html>
复制代码
在视图直接引用
@section Css{
<link href="@Url.Content("~/Content/AdminCss/Article.css")" rel="Stylesheet" type="text/css" />
}
View Code
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
添加css可以按楼上说的
通常我会把CSS |RenderSection加在头,js加在末尾
View Code
复制代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
@RenderSection("Meta",false)
<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("Css",false)
</head>
<body>
@RenderBody()
@RenderSection("Js",false)
</body>
</html>
复制代码
在视图直接引用
@section Css{
<link href="@Url.Content("~/Content/AdminCss/Article.css")" rel="Stylesheet" type="text/css" />
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询