我有一个 web 应用程序,我必须在其中为此部分指定一个新的 css 文件:
<section id="loginForm" >
<h2>Connecter à notre application</h2>
@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Formulaire de connexion</legend>
<ol>
<li>
@Html.Label("Name")
@Html.TextBox("Name")
</li>
<li>
@Html.Label("Password")
@Html.Password("Password")
</li>
</ol>
<input type="submit" value="Se connecter" />
</fieldset>
}
</section>
例如,hole View 与 css 文件 X
相关联,而我只想为该部分关联另一个 Y
css 文件。
我该怎么做?
最佳答案
Scoped CSS 即将推出,但支持还不是很好。在这里阅读更多:http://css-tricks.com/saving-the-day-with-scoped-css/和 http://html5doctor.com/the-scoped-attribute/#link
与此同时,另一种方法是在 Y
CSS 文件中为所有选择器添加前缀 #loginForm
。使用像 SASS 或 LESS 这样的预处理器,这很容易(将文件内容包装一次),但在纯 CSS 中变得非常乏味。
关于html - 在 Web 应用程序中更改 css 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17143456/