引导程序无法在 Visual Studio 2017 中正常工作 [英] bootstrap not working properly with visual studio 2017

查看:20
本文介绍了引导程序无法在 Visual Studio 2017 中正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 Visual Studio 2017 中使用引导程序创建轮播.我使用 NuGet 包管理器安装了 jquery 和 bootstrap.为了检查它的工作情况,我为轮播生成了一个引导程序片段.

代码如下:

<头><meta charset="utf-8"/><title>主页</title><link href="Content/bootstrap.min.css" rel="stylesheet"/><身体><div class="容器"><div class="row"><div id="my-carousel" class="carousel slide" data-ride="carousel"><!-- 指标--><ol class="carousel-indicators"><li data-target="#my-carousel" data-slide-to="0" class="active"></li><li data-target="#my-carousel" data-slide-to="1"></li><li data-target="#my-carousel" data-slide-to="2"></li></ol><!-- 幻灯片包装器--><div class="carousel-inner" role="listbox"><div class="item active"><img alt="第一张幻灯片" src="http://placehold.it/1200x675&text=First+slide">

<div class="item"><img alt="第二张幻灯片" src="http://placehold.it/1200x675&text=Second+slide">

<div class="item"><img alt="第三张幻灯片" src="http://placehold.it/1200x675&text=Third+slide">

<!-- 控件--><a class="left carousel-control" href="#my-carousel" role="button" data-slide="prev"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="sr-only">以前的</span></a><a class="right carousel-control" href="#my-carousel" role="button" data-slide="next"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="sr-only">下一步</span></a>

<script src="Scripts/jquery-3.3.1.min.js"></script><script src="Scripts/bootstrap.min.js"></script></html>

上述代码的输出与预期不同,因为所有图片幻灯片都放置在另一个下方,而不是作为轮播.

解决方案

使用正确的结构Bootstrap 4 Carousel.

您使用的标记适用于 3.x.例如 .item 现在是 .carousel-item.

I am try to create a carousel using bootstrap in visual studio 2017. I installed jquery and bootstrap using NuGet package manager. And to check its working, i generated a bootstrap snippet for carousel.

Here's the code:

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <title>Homepage</title>
  <link href="Content/bootstrap.min.css" rel="stylesheet" />
</head>

<body>

  <div class="container">
    <div class="row">
      <div id="my-carousel" class="carousel slide" data-ride="carousel">
        <!-- Indicators -->
        <ol class="carousel-indicators">
          <li data-target="#my-carousel" data-slide-to="0" class="active"></li>
          <li data-target="#my-carousel" data-slide-to="1"></li>
          <li data-target="#my-carousel" data-slide-to="2"></li>
        </ol>

        <!-- Wrapper for slides -->
        <div class="carousel-inner" role="listbox">
          <div class="item active">
            <img alt="First slide" src="http://placehold.it/1200x675&text=First+slide">
          </div>
          <div class="item">
            <img alt="Second slide" src="http://placehold.it/1200x675&text=Second+slide">
          </div>
          <div class="item">
            <img alt="Third slide" src="http://placehold.it/1200x675&text=Third+slide">
          </div>
        </div>

        <!-- Controls -->
        <a class="left carousel-control" href="#my-carousel" role="button" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#my-carousel" role="button" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>
    </div>
  </div>

  <script src="Scripts/jquery-3.3.1.min.js"></script>
  <script src="Scripts/bootstrap.min.js"></script>

</body>

</html>

The output of the above code is not as expected, as all image slides are placed one below the other and not as a carousel.

解决方案

Use the correct structure for the Bootstrap 4 Carousel.

The markup you're using is for 3.x. For example .item is now .carousel-item.

这篇关于引导程序无法在 Visual Studio 2017 中正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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