【问题标题】:How to apply css and elemental styles to a ASP.net MVC 3 Web Application如何将 css 和元素样式应用于 ASP.net MVC 3 Web 应用程序
【发布时间】:2013-12-31 13:16:38
【问题描述】:

如何将 css 和元素样式应用于 ASP.net MVC 3 Web 应用程序。这里发布我当前的项目视图代码来解释我的问题。

@{
ViewBag.Title = "FranchIndex";
Layout = "~/Views/Shared/_LayoutMaster.cshtml";
}

<h2>FranchIndex</h2>

<div class="login-wrap">
            <div class="login-head">
                <h3>Franchise Login</h3>
            </div>
            <form action="#" method="get">
                <div class="login-form">
                    <ul>
                        <li><i class="icon-user"></i><input type="text" class="login-user-input" @Html.TextBoxFor(Model => Model.UserName)></li>
                        <li><i class="icon-key"></i><input type="password" class="login-pass-input" @Html.TextBoxFor(Model=>Model.Password)></li>
                    </ul>
                </div>
                <div class="login-action">
                    <button type="submit" class="backend-login-btn btn btn-block btn-large btn-inverse">Login</button>
                    <ul class="login-initial clearfix">
                        <li class="pull-left"><a href="#">Forgot Password?</a></li>
                        <li class="pull-right"><span class="rem-check"><input type="checkbox" checked></span>Remember Me</li>
                    </ul>
                </div>
            </form>
            @*<h5>If You are a Franchise,Please @Html.ActionLink("Login Here", "FranchIndex", "Login") </h5> *@
        </div>

【问题讨论】:

  • 您的问题我们不清楚。你到底在尝试什么?

标签: html asp.net css asp.net-mvc


【解决方案1】:

在_LayoutMaster.cshtml中包括:

 @Styles.Render("~/Content/common")

在 App_Start/bundleConfig.css 中

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        // Shared Styling
        bundles.Add(new StyleBundle("~/Content/common").Include(
                        "~/Css/Common.css",
                        "~/Css/jqueryui.css",
                        "~/Css/chosen.css"
                    ));
    }
}

或您拥有的个人样式 CSS 文件的任何组合。

终于在 global.asax 中:

 protected void Application_Start()
 {
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }

【讨论】:

  • 我必须包含在 _LayoutMaster.cshtml 中的位置
  • 与您在标准 HTML 页面中的位置完全相同 - 样式通常位于 元素中
猜你喜欢
  • 2010-12-22
  • 2010-10-12
  • 1970-01-01
  • 1970-01-01
  • 2010-09-21
  • 2017-10-04
  • 2012-08-03
  • 1970-01-01
相关资源
最近更新 更多