swiper网格布局

news/2024/5/19 18:46:34 标签: flex

需要引入:swiper相关插件,官网上有详细步骤
官网地址:https://www.swiper.com.cn/api/index.html
实现效果:
在这里插入图片描述
左滑:
在这里插入图片描述

html:

 <!-- 列表 -->
      <div class="lie-list">
        <div class="swiper-container">
          <div class="swiper-wrapper">
            <div
              class="swiper-slide"
              style="width: 0px"
              v-for="n in slideIcon"
              :key="n"
            >
              <div class="swiper-item">
                <img :src="n.imgUrl" alt="" />
                <span class="icon_title">{{ n.text }}</span>
                <p class="icon_smallTitle">{{ n.smallText }}</p>
              </div>
            </div>
          </div>
          <!-- 如果需要滚动条 -->
          <div class="swiper-scrollbar"></div>
        </div>
      </div>

css:

.icon_item {
  display: flex;
  flex-wrap: wrap;
  margin-right: 0.5rem;
}
.lie-list {
  width: 94%;
  height: 7.1rem;
  padding: 0 5%;
  background-color: #fff;
  box-sizing: border-box;
  position: absolute;
  top: 3.5rem;
  border-radius: 0.4rem;
  margin-left: 0.3rem;
  padding-bottom: 0.1rem;
}
.swiper-slide-active {
  width: auto !important;
}

.lie-list .swiper-container,
.lie-list .swiper-wrapper {
  width: 100%;
  height: 100%;
}
.lie-list .swiper-slide {
  height: 0rem;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin: 0.4rem 0;
}

.lie-list .swiper-slide a {
  display: flex;
  width: 25%;
}
.lie-list .swiper-slide a div {
  width: 100%;
  height: 50%;
  display: flex;
  margin: 0;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.swiper-item {
  padding-right: 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lie-list .swiper-slide div img {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0;
}

.icon_title {
  font-family: PingFang-SC-Bold;
  font-weight: 700;
  font-size: 0.35rem;
  width: 1.68rem;
  height: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  color: #333;
  text-align: center;
  line-height: 0.7rem;
}

.icon_smallTitle {
  margin-top: 0.02rem;
  font-family: PingFangSC-Regular;
  font-size: 0.2rem;
  color: #999;
  text-align: center;
  height: 0.3rem;
  line-height: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
}
.swiper-scrollbar {
  position: absolute;
  left: 30%;
  bottom: 5px;
  z-index: 50;
  height: 4px;
  width: 35%;
}

js:

mounted() {
    var swiper = new Swiper(".lie-list .swiper-container", {
      slidesPerView: 4, //一行显示4个
      slidesPerColumn: 2, //显示2行
      slidesPerColumnFill: "row", //行布局
      // 如果需要滚动条
      scrollbar: {
        el: ".swiper-scrollbar",
        hide: false,
        draggable: false,
        slidesPerView: true,
        snapOnRelease: true,
        dragSize: 20,
      },
    });
  },

注:
slidesPerColumnFill:
column:列布局
在这里插入图片描述

	row:行布局

在这里插入图片描述


http://www.niftyadmin.cn/n/843379.html

相关文章

面试前必刷 两线程交替输出1~100 多线程

利用同步块和if条件交替输出 建议手动实现一遍 public class PrintNumber extends Thread {private static int cnt 0;private int id;public PrintNumber(int _id) {id _id;}public void run() {while (cnt < 100) {if (cnt % 2 id) {synchronized (PrintNumber.class…

HTML练习之路05

如下图&#xff0c;要完成该界面的网页&#xff1a; 我们也可以把它看作是两个部分&#xff0c;左侧为图片&#xff0c;右侧为文本&#xff0c;首先我们将图片通过src导入,并且通过align设置为靠左侧。并且设置水平间距hspace,代码如下&#xff1a; 然后我们来设置右侧的文本内…

Sql server 2008 R2 配置管理工具服务显示远程过程调用失败:0x800706be(转载)

转自&#xff1a;http://www.cnblogs.com/daomul/p/3728321.html 今天在其他电脑配置 SQl server 2008 R2&#xff0c;安装完成后&#xff0c;发现打开配置管理工具服务 &#xff1a;显示远程过程调用失败:0x800706be 这样的错误提示 之前并没有遇到过这种问题&#xff0c;猜想…

vue 一个页面根据状态渲染不同的组件 使用currentView动态渲染

1.在当前vue页面导入所需要的组件 组件目录&#xff1a; 注&#xff1a;index.vue就是要渲染的页面 在data中定义变量&#xff1a; components: {submitVeterans: () > import("./submitVeterans"),veteransWait: () > import("./veteransWait"),…

面试前必刷 字节hard 删除无效的括号

给你一个由若干括号和字母组成的字符串 s &#xff0c;删除最小数量的无效括号&#xff0c;使得输入的字符串有效。 返回所有可能的结果。答案可以按 任意顺序 返回。 示例 1&#xff1a; 输入&#xff1a;s "()())()" 输出&#xff1a;["(())()",&quo…

php 注册审核

注册界面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns"http://www.w3.org/1999/xhtml"> <head> <meta http-equiv"Co…

HTML知识点汇总

多行后退按TAB键&#xff0c; 多行前移按SHIFTTAB <hr></hr>用单标签<hr/>更好&#xff0c;可以防止代码冗余 注释格式为&#xff1a;<!--注释 --> 标题标签设置(属于body部分&#xff0c;总共有6个等级)&#xff1a; <hn allign "对齐方式…

Leetcode 76 最小覆盖子串

给你一个字符串 s 、一个字符串 t 。返回 s 中涵盖 t 所有字符的最小子串。如果 s 中不存在涵盖 t 所有字符的子串&#xff0c;则返回空字符串 "" 。 注意&#xff1a; 对于 t 中重复字符&#xff0c;我们寻找的子字符串中该字符数量必须不少于 t 中该字符数量。 如…