Bootstrap Carousel中的幻灯片不是水平形式,幻灯片只是垂直移动

问题描述 投票:0回答:2

当前行为Bootstrap Carousel中的幻灯片不会到来,幻灯片只会垂直移动。在旋转木马中,我们希望幻灯片只能水平放置,我还附加了当前的行为截图。

enter image description here

预期的行为旋转木马中的幻灯片应该像下面的示例屏幕截图一样水平(示例链接https://ng-bootstrap.github.io/#/components/carousel/examples

enter image description here从github链接https://github.com/gg-gg-v1/v1_ComponentsWithSEO运行npm install run ng serve --o下载代码后,用指令最小化再现问题 - 将在浏览器中启动

示例存储库https://github.com/gg-gg-v1/v1_ComponentsWithSEO

环境角度CLI:6.2.1节点:8.11.3 OS:win32 x64 Angular:6.1.7 ...动画,通用,编译器,编译器 - cli,核心,表单... http,语言服务,平台浏览器。 ..平台 - 浏览器 - 动态,平台 - 服务器,路由器

slider.component.ts

import { Component, OnInit } from '@angular/core';
import { NgbCarouselConfig } from '@ng-bootstrap/ng-bootstrap';

@Component({
  selector: 'app-slider',
  templateUrl: './slider.component.html',
  styleUrls: ['./slider.component.css'],
  providers: [NgbCarouselConfig]  // add NgbCarouselConfig to the component providers
})
export class SliderComponent implements OnInit {
  images = [1, 2, 3, 4].map(() => `https://picsum.photos/900/500?random&t=${Math.random()}`);

  constructor(config: NgbCarouselConfig) {
    // customize default values of carousels used by this component tree
    config.interval = 10000;
    config.wrap = false;
    config.keyboard = false;
    config.pauseOnHover = false;
  }
  ngOnInit() {
      }
}

slider.component.html

  <ngb-carousel *ngIf="images">
      <ng-template ngbSlide>
        <img [src]="images[0]" alt="Random first slide">
        <div class="carousel-caption">
          <h3>10 seconds between slides...</h3>
          <p>This carousel uses customized default values.</p>
        </div>
      </ng-template>
      <ng-template ngbSlide>
        <img [src]="images[1]" alt="Random second slide">
        <div class="carousel-caption">
          <h3>No mouse events...</h3>
          <p>This carousel doesn't pause or resume on mouse events</p>
        </div>
      </ng-template>
      <ng-template ngbSlide>
        <img [src]="images[2]"  alt="Random third slide">
        <div class="carousel-caption">
          <h3>No keyboard...</h3>
          <p>This carousel uses customized default values.</p>
        </div>
      </ng-template>
      <ng-template ngbSlide>
        <img [src]="images[3]" alt="Random fourth slide">
        <div class="carousel-caption">
          <h3>And no wrap after last slide.</h3>
          <p>This carousel uses customized default values.</p>
        </div>
      </ng-template>
    </ngb-carousel>
angular carousel
2个回答
0
投票

你没有导入bootstrap.css。在angular.json样式数组或index.html中导入,直接给它cdn引用:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />

0
投票

你需要安装bootstrap:npm install bootstrap @ 4链接它(通过index.html),相同的代码将工作

这也记录在https://github.com/ng-bootstrap/ng-bootstrap/issues/2141

© www.soinside.com 2019 - 2024. All rights reserved.