首页 > 解决方案 > Angular Swiper 宽度在调整大小时不断增加

问题描述

我目前正在 Angular 应用程序上制作横幅,但它无法正常工作。问题是子元素的宽度在调整窗口大小时不断增加。

这是我的代码快照以获取更多信息:

    <swiper
        [slidesPerView]="3"
        [loop]="true"
        [resizeObserver]="true"
        class="spp-swiper"
    >
        <ng-template swiperSlide *ngFor="let article of articles">
            <img class="spp-banner" src="{{ article.img }} />
        </ng-template>
    </swiper>

我使用 scss 作为样式,并导入了以下 swiper 模块样式。


@import "./../node_modules/swiper/swiper.scss";
@import "./../node_modules/swiper/components/pagination/pagination.scss";

你有没有遇到过这样的问题?

标签: angularsassswiper

解决方案


我找到了解决方案,解决方案是将 flex 布局应用于父包装元素。


推荐阅读