swiper网格布局

swiper网格布局需要引用 使用前需要引用 swiper css 文件以及 swiper js 文件 html 选项列表 divclass lie list divclass swiper container divclass swiper wrapper divclass swiper wrapper divclass swiper container divclass lie list

需要引用:

使用前需要引用swiper.css文件以及swiper.js文件

html:

  
    <div class="lie-list"> <div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide"> <div> <img src="" alt=""> <span>测试测试 
     span>  
      div>  
       div>  
        div>  
         div>  
          div> 

css:

.lie-list { 
    width: 100%; height: 12rem; margin: 0 auto; padding: 0 5%; display: flex; justify-content: flex-start; align-items: flex-start; background-color: #fff; box-sizing: border-box; } .lie-list .swiper-container, .lie-list .swiper-wrapper { 
    width: 100%; height: 100%; } .lie-list .swiper-slide { 
    height: 100%; width: 100%; display: flex; flex-wrap: wrap; justify-content: flex-start; padding: 0; margin: 0; } .lie-list .swiper-slide a { 
    display: flex; width: 25%; } /* .lie-list .swiper-slide .lie { width: 100%; height: 49%; display: flex; justify-content: space-between; border: 1px solid black; } */ .lie-list .swiper-slide a div { 
    width: 100%; height: 50%; display: flex; margin: 0; justify-content: center; align-items: center; flex-wrap: wrap; } .lie-list .swiper-slide div img { 
    width: 3rem; height: 3rem; border-radius: 0; margin-bottom: 0.3rem; } .lie-list .swiper-slide div span { 
    /* color: #ffffff; */ font-size: 0.9rem; color: #3A3A3A; display: flex; justify-content: center; align-items: center; width: 100%; } 

js:

 var swiper = new Swiper('.lie-list .swiper-container', { 
    slidesPerView: 4, //一行显示4个 slidesPerColumn: 2, //显示2行 slidesPerColumnFill: 'row', //行布局 }); 

实际效果:

 row:行布局 

在这里插入图片描述

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/214281.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月18日 下午4:37
下一篇 2026年3月18日 下午4:37


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号