bootstrap主题在ASP.Net MVC 5项目中不起作用

时间:2018-02-17 16:00:18

标签: asp.net model-view-controller bootswatch

我已经从bootswatch.com下载了名为flatly的bootstrap主题。我已使用How can I implement a theme from bootswatch or wrapbootstrap in an MVC 5 project?中的说明进行设置。 但我的引导主题仍然无法正常工作。它给了我很多警告。我已将已下载的flatly.bootstrap.css主题复制到Content目录并修改了Bundleconfig.cs文件,我添加了新的bundle:bundles.Add(new StyleBundle("〜/ Content / css")。Include(                       "〜/内容/ flatly.bootstrap.css&#34 ;,                       "〜/内容/的site.css&#34));但该主题无法正常工作:这是我的网站website image的截图 谁可以帮我解决这个问题?另请观看图片:Warnings image

2 个答案:

答案 0 :(得分:2)

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

<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>

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

<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>

答案 1 :(得分:0)

您正在使用Bootstrap版本4,其中包含对版本3的更改,这是ASP.NET模板正在使用的版本。您可以使用Nuget包管理器回滚Bootstrap 4到3,也可以将migrate回滚到版本4。