简体   繁体   中英

ngx-gallery not displaying left-right arrow over image in Angular

I am using ngx-gallery to display an image gallery. Although I set the display image arrow property to be true, I can't see the arrows in the image.

I am using Angular 7. This is my gallery.ts file code:

 galleryOptions: NgxGalleryOptions[];
  galleryImages: NgxGalleryImage[];

  ngOnInit(): void {

      this.galleryOptions = [
          {
              'previewCloseOnEsc': true,
              'previewKeyboardNavigation': true,
              'imageBullets': true,
              'imageAutoPlay': true,
              width: '100%',
              height: '400px',
              thumbnailsColumns: 4,
              imageAnimation: NgxGalleryAnimation.Slide
          },
          // max-width 800
          {
              breakpoint: 800,
              width: '100%',
              height: '600px',
              imagePercent: 90,
              thumbnailsPercent: 10,
              thumbnailsMargin: 20,
              thumbnailMargin: 20
          },
          // max-width 400
          {
              breakpoint: 400,
              preview: false
          }
      ];

      this.galleryImages = [
          {
              small: 'assets/1-small.png',
              medium: 'assets/1-medium.png',
              big: 'assets/1-big.png'
          },
          {
              small: 'assets/2-small.png',
              medium: 'assets/2-medium.png',
              big: 'assets/2-big.png'
          },
          {
              small: 'assets/3-small.png',
              medium: 'assets/3-medium.png',
              big: 'assets/3-big.png'
          },
          {
            small: 'assets/4-small.png',
            medium: 'assets/4-medium.png',
            big: 'assets/4-big.png'
        }
      ];
  }

I have also changed the css as described in some forum:

ngx-gallery /deep/ ngx-gallery-image .ngx-gallery-arrow {
  background-color: orangered;
}
ngx-gallery /deep/ ngx-gallery-thumbnails .ngx-gallery-arrow {
  background-color: orangered;
}
ngx-gallery /deep/ ngx-gallery-preview .ngx-gallery-arrow {
  background-color: orangered;
}

This is my gallery.html code

<ngx-gallery [options]="galleryOptions" [images]="galleryImages"></ngx-gallery>

ngx-gallery needs font awesome to display left-right arrow icon. Try including them in your angular-cli.json file. according to their documentation you can include them like this

"styles": [
...
"../node_modules/font-awesome/css/font-awesome.css"

]

You can also include font-awesome.css directly in your index.html file.

Also include hammer.js for swipe. import in your module like this

npm install hammerjs --save

import 'hammerjs';

you may also need bootstrap to use ngx-gallery properly.

i solved using

@import url(../node_modules/font-awesome/css/font-awesome.css);

in "styles.css"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM