简体   繁体   English

在Web应用程序中更改CSS文件

[英]Changing css file in a web application

I have a web aplication , in which i have to specify a new css file to this section : 我有一个网络应用程序,其中我必须为此部分指定一个新的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>

For example , the hole View is associated with the css file X and i'd like to associate another Y css file only for this section. 例如,hole View与css文件X关联,而我只想为此部分关联另一个Y css文件。

How can i do this? 我怎样才能做到这一点?

Scoped CSS is coming, but the support isn't very good yet. 范围CSS即将推出,但支持还不是很好。 Read more here: http://css-tricks.com/saving-the-day-with-scoped-css/ and http://html5doctor.com/the-scoped-attribute/#link 在此处了解更多信息: http : //css-tricks.com/saving-the-day-with-scoped-css/http://html5doctor.com/the-scoped-attribute/#link

In the meantime, an alternative is to prefix all your selectors in your Y css file with #loginForm . 同时,另一种方法是在您的Y css文件中的所有选择器#loginForm加上#loginForm With a preprocessor like SASS or LESS, this is very easy (wrap the file contents once), but becomes very tedious in plain CSS. 使用像SASS或LESS这样的预处理器,这非常容易(将文件内容包装一次),但是在普通CSS中变得非常繁琐。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM