【发布时间】:2014-01-17 07:28:41
【问题描述】:
我是 asp.net 中 RAZOR 语法 + mvc 的新手。我是 webforms 的老手,在这方面做了很多工作,但现在我不知道如何将 CSS 应用于我的 DIV 容器。 在我以前做的网络表单中:
div
{
width: 200px
background-color: blue;
}
现在如何在剃刀视图中执行此操作?
我的代码:
@{
ViewBag.Title = "Home Page";
}
@using (Html.BeginForm("register","Home", FormMethod.Post, new {id="submitForm"}))
{
<div style="Width:200px">
<i>@Html.Label("Name:")</i>
@Html.TextBox("txtboxName")
</div>
<br />
<div style="Width:200px">
<i>@Html.Label("Email:")</i>
@Html.TextBox("txtboxEmail")
</div>
<br />
<div style="Width:200px">
<i>@Html.Label("Password:")</i>
@Html.Password("txtboxPassword")
</div>
<br />
<div>
<button type="submit" id="btnSubmit" name="Command" value="Submit">Submit</button>
</div>
}
【问题讨论】:
-
MVC 与样式包一起使用,您想要的所有 CSS 文件都存在。见Styles.Render in MVC4。
-
这与剃须刀无关。这只是css和html的问题。你需要澄清你的确切问题是什么。 css 是在正确的 .css 文件中还是在 .cshtml 中?是否加载了css?你错过了一个;在你的 CSS 中。
标签: css asp.net-mvc razor