bootstrap 主题在 ASP.Net MVC 5 项目中不起作用 [英] bootstrap theme not working in ASP.Net MVC 5 project

查看:75
本文介绍了bootstrap 主题在 ASP.Net MVC 5 项目中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从 bootswatch.com 下载了名为 flatly 的引导程序主题.我已经使用 如何在 MVC 5 项目中从 bootswatch 或 wrapbootstrap 实现主题?.但是我的引导主题仍然无法正常工作.它给了我很多警告.我已将下载的 flatly.bootstrap.css 主题复制到 Content 目录并修改了 Bundleconfig.cs 文件,我添加了新包:bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/flatly.bootstrap.css","~/Content/site.css"));但该主题无法正常工作:这是我的网站截图 网站图片谁能帮我解决这个问题?另请观看附加图片:警告图片

解决方案

更改 _Layout.cshtml 中的导航栏"代码.您可能已经在使用以下代码 -

<div class="navbar-collapse collapse"><ul class="nav navbar-nav"><li>@Html.ActionLink("Home", "Index", "Home")</li><li>@Html.ActionLink("About", "About", "Home")</li><li>@Html.ActionLink("Contact", "Contact", "Home")</li>@Html.Partial("_LoginPartial")

将其替换为来自 getbootstrap.com 的以下内容.但在此之前,请确保您已经下载/安装了 bootstrap 4.0(我是通过 Nuget 包管理器完成的).您可以在其上添加自定义 -

<li class="nav-item"><a class="nav-link disabled" href="#">Disabled</a><form class="form-inline my-2 my-lg-0"><input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search"><button class="btn btn-outline-success my-2 my-sm-0" type="submit">搜索</button></表单>

</nav>

I have downloaded bootstrap theme named flatly from bootswatch.com. I have set it up using instructions from How can I implement a theme from bootswatch or wrapbootstrap in an MVC 5 project?. But my bootstrap theme still not working. It gives me lots of warnings. I have copied downloaded flatly.bootstrap.css theme to Content directory and modified Bundleconfig.cs file, i have added new bundle: bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/flatly.bootstrap.css", "~/Content/site.css")); but that theme not working correctly: here is my screenshot of my website website image Who can help me with this issue? Also watch image attached:Warnings image

解决方案

Change your 'navbar' code code in _Layout.cshtml. You might be already using the below code -

<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            @Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li>@Html.ActionLink("Home", "Index", "Home")</li>
                <li>@Html.ActionLink("About", "About", "Home")</li>
                <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
            </ul>
            @Html.Partial("_LoginPartial")
        </div>
    </div>
</div>

Replace it with below one from getbootstrap.com. But before that ensure that you have downloaded/installed bootstrap 4.0 (I have done it via Nuget package manager). You can add your customization on it -

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">Navbar</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Dropdown
        </a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
          <a class="dropdown-item" href="#">Action</a>
          <a class="dropdown-item" href="#">Another action</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="#">Something else here</a>
        </div>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>
    <form class="form-inline my-2 my-lg-0">
      <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
      <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
    </form>
  </div>
</nav>

这篇关于bootstrap 主题在 ASP.Net MVC 5 项目中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
C#/.NET最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆