当前位置: 首页 > news >正文

vue3 实现一个数组项在水平轴上按照奇偶数项分别上下排列

组件完整代码:

<template><div class="h-full"><div class="h-full scroll-container"><div class="flex flex-row mt-[60rem]"><div v-for="(ele, i) in DataList" :key="'i'+i" class="grid-item flex flex-col items-center"><div class="grid-top h-[162rem] pt-[21rem]"><div class="grid-img flex justify-center"><NuxtImg :src="ele.img" alt="alt" class="object-cover" /></div></div><div class="grid-line flex flex-col"><div class="relative h-[50rem]"><div class="t-line"><svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="52rem" viewBox="0 0 2 52" fill="none"><path d="M1 51L1 1" stroke="#FF4500" stroke-linecap="round" /></svg></div></div><div class="relative"><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="2rem" viewBox="0 0 1055 2" fill="none"><path d="M-91 1H1054" stroke="#0000FF" stroke-linecap="round" /></svg><div class="w-[18rem] h-[18rem] absolute left-[50%] ml-[-9rem] mt-[-9rem]"><svg xmlns="http://www.w3.org/2000/svg" width="18rem" height="18rem" viewBox="0 0 49 49" fill="none"><g filter="url(#filter0_di_1963_1519)"><circle cx="24.5" cy="24.5" r="11.5" fill="#03BBBF" /><circle cx="24.5" cy="24.5" r="9.58333" stroke="white" stroke-width="3.83333" /></g><defs><filter id="filter0_di_1963_1519" x="0.222222" y="0.222222" width="48.5556" height="48.5556" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix" /><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" /><feOffset /><feGaussianBlur stdDeviation="6.38889" /><feComposite in2="hardAlpha" operator="out" /><feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0" /><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1963_1519" /><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1963_1519" result="shape" /><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" /><feOffset /><feGaussianBlur stdDeviation="7.53889" /><feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1" /><feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0" /><feBlend mode="normal" in2="shape" result="effect2_innerShadow_1963_1519" /></filter></defs></svg></div></div></div><div class="grid-bot h-[162rem] flex"><div><div class="b-title">{{ ele.title }}</div><div class="b-desc">{{ ele.desc }}</div></div></div></div></div></div></div>
</template><script lang="ts" setup>
const DataList = ref([{title: 'Pic title 1',desc: 'Pic desc 1',img: 'https://picsum.photos/400/300?random=1',},{title: 'Pic title 2',desc: 'Pic desc 2',img: 'https://picsum.photos/400/300?random=2',},{title: 'Pic title 3',desc: 'Pic desc 3',img: 'https://picsum.photos/400/300?random=3',},{title: 'Pic title 4',desc: 'Pic desc 4',img: 'https://picsum.photos/400/300?random=4',},{title: 'Pic title 5',desc: 'Pic desc 5',img: 'https://picsum.photos/400/300?random=5',},
])
</script>
<style scoped>
.scroll-container {background-color: darkseagreen;/* background-image: url('https://picsum.photos/400/300?random=0'); */background-size: cover;background-repeat: no-repeat;background-position: center;width: 100%;height: 100%;max-width: 100vw; /* 固定为视口宽度,避免内容撑宽页面 */padding: 80rem 0 96rem 0;
}.line-wapper {width: 100%;height: 2rem;background-color: #b5b5b5;
}.grid-item {text-align: center;flex: 1;
}.grid-item:nth-child(2n) {margin-top: 50rem;flex-direction: column-reverse;
}.grid-top {border-radius: 16rem;background: linear-gradient(323deg,rgba(255, 255, 255, 0.7) -20.1%,rgba(255, 255, 255, 0.28) 136.24%);
}.grid-img {width: 121rem;height: 121rem;
}.grid-img img {width: 100%;height: auto;
}.grid-item:nth-child(2n) .grid-line {flex-direction: column-reverse;
}.grid-item:nth-child(2n + 1) .grid-bot {padding-top: 22rem;
}.grid-item:nth-child(2n) .grid-bot {padding-bottom: 22rem;align-items: flex-end;
}.b-title {margin-bottom: 4rem;@apply text-[#1A1C20] text-[20rem] leading-[140%] tracking-[-0.2rem];font-family: PoppinsZN-600;
}.b-desc {@apply text-[rgba(26,28,32,0.45)] text-[12rem] leading-[130%] tracking-[-0.12rem] opacity-65;font-family: PoppinsZN-600;
}.t-line {position: absolute;left: 50%; /* 将元素左边缘定位到父容器50%的位置 */transform: translateX(-50%); /* 向左移动自身宽度的50%,实现水平居中 */
}
</style>

页面效果如下:
在这里插入图片描述

http://www.dtcms.com/a/495904.html

相关文章:

  • 服装类电子商务网站建设报告网页突然打不开是什么原因
  • 激光散斑血流图像去噪技术研究及其MATLAB实现
  • 帝国cms下载类网站怎么做怎么才能注册网站
  • 自助制作网站简述网站建设方法
  • java微服务-尚医通-数据字典-5
  • 建设营销型网站模板如何修改公司网站内容
  • 江西临川建设集团有限公司网站湖南网站建设 尖端磐石网络
  • 深圳保障性住房排名查询换个网站对seo有什么影响
  • 提升后牙树脂充填效率的器械选择要点
  • YOLO-V3
  • 论部落战争对两性思维的终极塑造及其政治遗产​​
  • Java 12的性能优化对不同规模和类型的应用程序有何影响?
  • 深入解析 Cherry Studio 的创建的本地知识库并用于问答的过程
  • 做图网站被告wordpress 学校主题
  • Joomla SQL注入漏洞复现:原理详解+环境搭建+渗透实践(CVE-2017-8917 两种方法渗透)
  • 天津网站优化公司哪家好一个公网ip可以做几个网站
  • 【SpringBoot 快速上手实战系列】5 分钟用 Spring Boot 搭建一个用户管理系统(含前后端分离)!新手也能一次跑通!
  • 什么网站源码做分类信息网站好WordPress巨卡无比
  • 网站不绑定域名解析网络优化app哪个好
  • 数据结构(4)--------------- 串
  • 湖北网站建设网址上海有哪些做网站的
  • 最新vmware安装kali
  • 端口号、常见协议和套接字
  • YOLOv3 核心知识点解析
  • 企业网站建设费怎么记账最近时政热点新闻
  • 2022年ASOC SCI2区TOP,基于竞争与合作策略的金字塔粒子群算法PPSO,深度解析+性能实测,深度解析+性能实测
  • 深入理解C++中的浅拷贝与深拷贝:从类的拷贝函数开始
  • 公网站建设浙江最新通知今天
  • 免费高效的一站式解决多种文件处理需求的PC工具箱
  • ESXI主机重置带外密码