【发布时间】:2021-10-31 01:37:33
【问题描述】:
我一直在尝试添加一个 css 文件来设置 cshtml 文件的样式,但到目前为止我没有成功。
这是我尝试做的:
@model mvc.Models.LoginViewModel
@{
ViewData["Title"] = "Login";
}
<head>
<div class="text-center">
<h1 class="display-4">Login Page</h1>
</div>
<link rel="stylesheet" href="~/Content/login.css" type="text/css" />
</head>
Here is the directory tree with the two files I'm trying to link
编辑:当我将 css 样式放在 cshtml 中的“样式”标签中时,它就可以工作了。我希望有一种方法可以使用 css 文件。
你能帮帮我吗? 谢谢。
【问题讨论】:
-
这能回答你的问题吗? How to add a .css to a .cshtml
-
我试过了,但对我没用。
-
和
href="/Content/login.css" -
../../Content/login.css 你需要最多 2 个文件夹。现在你的链接 Views/content/login.css 你需要去 /Content/login.css
-
我尝试上两个文件夹,还是不行。
标签: html css asp.net asp.net-core