Search code examples
htmlcssangulartypescriptng-bootstrap

Angular/ng-bootstrap - Carousel Arrow Customization


I'm trying to change the positioning and icon of the given control arrows by bootstrap. I've tried to adress "carousel-control-prev-icon" & "carousel-control-next-icon", but nothing changes. Does anyone know a proper solution?

HTML:

<div class="container">
  <div class="row">
    <div class="col-12">
      <ngb-carousel *ngIf="images">
        <ng-template ngbSlide>
          <img [src]="images[0]" alt="Random first slide">
        </ng-template>
        <ng-template ngbSlide>
          <img [src]="images[1]" alt="Random second slide">
        </ng-template>
        <ng-template ngbSlide>
          <img [src]="images[2]" alt="Random third slide">
        </ng-template>
      </ngb-carousel>
  </div>
  </div>
</div>

CSS:

ngb-carousel {
    width: 900px;
}

.carousel-control-prev-icon{
    background-image: url('https://apufpel.com.br/assets/img/seta_prim.png')
 }
 .carousel-control-next-icon{
   background-image: url('https://apufpel.com.br/assets/img/seta_ult.png')
 }

TypeScript:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent {

  images = ['assets/images/image1.jpg', 'assets/images/image2.jpg', 'assets/images/image3.jpg'];

}

Thanks in advance, Tim


Solution

  • Try to make your CSS including important because of NGB carousel CSS override this CSS that you are including into your component.css file as below

    ngb-carousel {
      width: 900px;
    }
    
    .carousel-control-prev-icon{
     background-image: url('https://apufpel.com.br/assets/img/seta_prim.png') !important;
    }
    .carousel-control-next-icon{
       background-image: url('https://apufpel.com.br/assets/img/seta_ult.png')!important;
    }
    

    Hope this will help!!