vue v-for展示元素分两栏 中间使用分割线

1.效果展示:

2.代码展示:

<template>
  <div class="container">
    <div class="column" v-for="(item, index) in items" :key="index">
      <div class="item">{{ item }}</div>
      <div v-if="index % 2 !== 0" class="divider"></div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      items: ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5']
    };
  }
};
</script>

<style scoped>
.container {
  display: flex;
  flex-wrap: wrap;

}

.column {
  flex: 0 0 50%; /* 每个元素占据50%的宽度 */
  max-width: 50%;
  padding: 10px;
  box-sizing: border-box;
  position: relative;
}

.item {
  background-color: #f0f0f0;
  padding: 20px;
  margin-bottom: 10px;
}

.divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px; /* 分割线的宽度 */
  background-color: #ccc; /* 分割线的颜色 */
  margin-left: -10px;
}
</style>

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 05:24:01       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 05:24:01       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 05:24:01       58 阅读
  4. Python语言-面向对象

    2024-07-19 05:24:01       69 阅读

热门阅读

  1. 【16】时间单位换算

    2024-07-19 05:24:01       18 阅读
  2. 10 - FFmpeg - 重采样 - SoftwareResampleExample

    2024-07-19 05:24:01       17 阅读
  3. npm install时报错 reason: connect ETIMEDOUT

    2024-07-19 05:24:01       16 阅读
  4. npm相关指令

    2024-07-19 05:24:01       23 阅读
  5. 【Unity】RPG2D龙城纷争(十四)存档系统

    2024-07-19 05:24:01       19 阅读
  6. 点的距离(C++)

    2024-07-19 05:24:01       20 阅读
  7. itextpdf 使用demo

    2024-07-19 05:24:01       26 阅读
  8. chatglm2-6b-prompt尝试

    2024-07-19 05:24:01       21 阅读
  9. IKM 外企常用

    2024-07-19 05:24:01       21 阅读
  10. Linux源码阅读笔记13-进程通信组件上

    2024-07-19 05:24:01       20 阅读
  11. 分布式唯一id的7种方案

    2024-07-19 05:24:01       24 阅读
  12. 编程中的智慧之设计模式三

    2024-07-19 05:24:01       21 阅读