SVG 画出动态线条流动效果

2024-02-21 23:08
文章标签 动态 效果 svg 流动 线条

本文主要是介绍SVG 画出动态线条流动效果,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

版權聲明: 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

最近做了一个项目 UI图长这样

中间的线条没有gif 需要用代码画出来
尝试了很多种方法 最终选择了用svg画

下面是全部的代码

<template><div class="right-page"><Subtitles :hanzi="title.zh" :yingyu="title.en" class="title"></Subtitles><div class="tab-box"><divclass="tab-item"v-for="(item, index) in TabList":key="index":class="{ active: currentIndex === index }"@click.stop="activeClick(index)">{{ item }}</div></div><imgsrc="../img/leftbtn.png"alt=""class="leftBtn"@click.stop="leftBtnClick"/><imgsrc="../img/leftbtn.png"alt=""class="rightBtn"@click.stop="rightBtnClick"/><img src="../img/xiamtu.png" alt="" class="tab-content" /><!--  4条svg 线条 --><div class="container"><div class="line-wrap"><!-- 111 --><svgversion="1.1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"xml:space="preserve"class="circle-load-rect-svg"viewbox="0 0 600 400"><polyline:points="svgData[currentIndex][0]"fill="none"class="g-rect-path"stroke="#007084"/><polyline:points="svgData[currentIndex][0]"fill="none"class="g-rect-fill"stroke="#00e9f9"/></svg><!-- 222 --><svgversion="1.1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"xml:space="preserve"class="circle-load-rect-svg"viewbox="0 0 600 400"><polyline:points="svgData[currentIndex][1]"fill="none"class="g-rect-path"stroke="#805c2c"/><polyline:points="svgData[currentIndex][1]"fill="none"class="g-rect-fill"stroke="#feee3c"/></svg><!-- 333 --><svgversion="1.1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"xml:space="preserve"class="circle-load-rect-svg"viewbox="0 0 600 400"><polyline:points="svgData[currentIndex][2]"fill="none"class="g-rect-path"stroke="#19875c"/><polyline:points="svgData[currentIndex][2]"fill="none"class="g-rect-fill"stroke="#3aeca1"/></svg><!-- 444 --><svgversion="1.1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"xml:space="preserve"class="circle-load-rect-svg"viewbox="0 0 600 400"><polyline:points="svgData[currentIndex][3]"fill="none"class="g-rect-path"stroke="#18808e"/><polyline:points="svgData[currentIndex][3]"fill="none"class="g-rect-fill"stroke="#36f4fb"/></svg></div></div><span class="bottom-title">信息机房应用成效</span></div>
</template><script>
import Subtitles from '../../../publicoComponents/Subtitles.vue'export default {props: {},data () {return {title: {zh: '信息机房应用成效',en: 'Application effectiveness of information room'},TabList: ['联通互通', '云边协作', '数字可视化', '系统对接'],currentIndex: 0,svgData: [['200,0 200,30 930,30 930,97', '180,0 180,50 753,50 753,97', '160,0 160,70 580,70 580,97', '140,0 140,90 405,90 405,96'],['530,0 530,30 930,30 930,97', '510,0 510,50 753,50 753,97', '490,0 490,70 580,70 580,97', '470,0 470,90 405,90 405,96'],['860,0 860,97 930,97 930,97', '840,0 840,50 840,97 753,97', '820,0 820,83 580,83 580,97', '800,0 800,70 405,70 405,96'],['1190,0 1190,97 930,97 930,97', '1170,0 1170,83 753,83 753,97', '1150,0 1150,70 580,70 580,97', '1130,0 1130,58 405,58 405,96']]}},computed: {},mounted () {},methods: {activeClick (index) {this.currentIndex = index},leftBtnClick () {if (this.currentIndex === 0) {this.currentIndex = 3return}this.currentIndex--},rightBtnClick () {if (this.currentIndex === 3) {this.currentIndex = 0return}this.currentIndex++}},components: {Subtitles}
}
</script><style scoped lang="less">
.right-page {height: 100%;background-image: url("../img/dizuo.png");background-repeat: no-repeat;background-position: 50% 90%;position: relative;
}
.title {padding-top: 30px;
}
.tab-box {display: flex;width: 1320px;margin: 0 auto;padding-top: 80px;.tab-item {background-image: url("../img/3hdfa.png");background-repeat: no-repeat;background-position: center;width: 224px;margin: 0 auto;height: 164px;line-height: 122px;text-align: center;color: #fff;font-size: 24px;font-family: MicrosoftYaHei;opacity: 0.6;}.active {opacity: 1;}
}
.leftBtn {position: absolute;top: 19.5%;left: 13%;
}
.rightBtn {position: absolute;transform: rotate(180deg);top: 19.5%;left: 84%;
}
.tab-content {position: absolute;left: 50%;top: 50%;transform: translate(-50%, -46%);
}
.container {width: 100%;margin-top: -20px;
}
.line-wrap {width: 1350px;margin: 0 auto;position: relative;
}
.line-wrap svg:nth-child(2) {position: absolute;top: 0;
}
.line-wrap svg:nth-child(3) {position: absolute;top: 0;
}
.line-wrap svg:nth-child(4) {position: absolute;top: 0;
}
.circle-load-rect-svg {width: 1350px;margin: 10px;
}.g-rect-path {fill: none;stroke-width: 3;stroke-linejoin: round;stroke-linecap: round;
}.g-rect-fill {fill: none;stroke-width: 5;stroke-linejoin: round;stroke-linecap: round;stroke-dasharray: 3, 900;stroke-dashoffset: -100;animation: lineMove 3s cubic-bezier(0, 0, 0.74, 0.74) infinite;
}@keyframes lineMove {0% {stroke-dashoffset: -850;}100% {stroke-dashoffset: -0;}
}
.bottom-title {position: absolute;bottom: 30%;width: 100%;font-size: 36px;font-family: Microsoft YaHei;font-weight: bold;color: #38dcff;text-align: center;line-height: 38px;background: linear-gradient(0deg, #2de9ff 0.146484375%, #2fa9ff 99.31640625%);-webkit-background-clip: text;-webkit-text-fill-color: transparent;
}
</style>

这篇关于SVG 画出动态线条流动效果的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/733380

相关文章

Android 悬浮窗开发示例((动态权限请求 | 前台服务和通知 | 悬浮窗创建 )

《Android悬浮窗开发示例((动态权限请求|前台服务和通知|悬浮窗创建)》本文介绍了Android悬浮窗的实现效果,包括动态权限请求、前台服务和通知的使用,悬浮窗权限需要动态申请并引导... 目录一、悬浮窗 动态权限请求1、动态请求权限2、悬浮窗权限说明3、检查动态权限4、申请动态权限5、权限设置完毕后

前端原生js实现拖拽排课效果实例

《前端原生js实现拖拽排课效果实例》:本文主要介绍如何实现一个简单的课程表拖拽功能,通过HTML、CSS和JavaScript的配合,我们实现了课程项的拖拽、放置和显示功能,文中通过实例代码介绍的... 目录1. 效果展示2. 效果分析2.1 关键点2.2 实现方法3. 代码实现3.1 html部分3.2

Java使用POI-TL和JFreeChart动态生成Word报告

《Java使用POI-TL和JFreeChart动态生成Word报告》本文介绍了使用POI-TL和JFreeChart生成包含动态数据和图表的Word报告的方法,并分享了实际开发中的踩坑经验,通过代码... 目录前言一、需求背景二、方案分析三、 POI-TL + JFreeChart 实现3.1 Maven

使用Python实现PDF与SVG互转

《使用Python实现PDF与SVG互转》SVG(可缩放矢量图形)和PDF(便携式文档格式)是两种常见且广泛使用的文件格式,本文将详细介绍如何使用Python实现SVG和PDF之间的相互转... 目录使用工具使用python将SVG转换为PDF使用Python将SVG添加到现有PDF中使用Python将PD

Java导出Excel动态表头的示例详解

《Java导出Excel动态表头的示例详解》这篇文章主要为大家详细介绍了Java导出Excel动态表头的相关知识,文中的示例代码简洁易懂,具有一定的借鉴价值,有需要的小伙伴可以了解下... 目录前言一、效果展示二、代码实现1.固定头实体类2.动态头实现3.导出动态头前言本文只记录大致思路以及做法,代码不进

vue基于ElementUI动态设置表格高度的3种方法

《vue基于ElementUI动态设置表格高度的3种方法》ElementUI+vue动态设置表格高度的几种方法,抛砖引玉,还有其它方法动态设置表格高度,大家可以开动脑筋... 方法一、css + js的形式这个方法需要在表格外层设置一个div,原理是将表格的高度设置成外层div的高度,所以外层的div需要

SpringBoot实现动态插拔的AOP的完整案例

《SpringBoot实现动态插拔的AOP的完整案例》在现代软件开发中,面向切面编程(AOP)是一种非常重要的技术,能够有效实现日志记录、安全控制、性能监控等横切关注点的分离,在传统的AOP实现中,切... 目录引言一、AOP 概述1.1 什么是 AOP1.2 AOP 的典型应用场景1.3 为什么需要动态插

VUE动态绑定class类的三种常用方式及适用场景详解

《VUE动态绑定class类的三种常用方式及适用场景详解》文章介绍了在实际开发中动态绑定class的三种常见情况及其解决方案,包括根据不同的返回值渲染不同的class样式、给模块添加基础样式以及根据设... 目录前言1.动态选择class样式(对象添加:情景一)2.动态添加一个class样式(字符串添加:情

SpringCloud配置动态更新原理解析

《SpringCloud配置动态更新原理解析》在微服务架构的浩瀚星海中,服务配置的动态更新如同魔法一般,能够让应用在不重启的情况下,实时响应配置的变更,SpringCloud作为微服务架构中的佼佼者,... 目录一、SpringBoot、Cloud配置的读取二、SpringCloud配置动态刷新三、更新@R

基于Python实现PDF动画翻页效果的阅读器

《基于Python实现PDF动画翻页效果的阅读器》在这篇博客中,我们将深入分析一个基于wxPython实现的PDF阅读器程序,该程序支持加载PDF文件并显示页面内容,同时支持页面切换动画效果,文中有详... 目录全部代码代码结构初始化 UI 界面加载 PDF 文件显示 PDF 页面页面切换动画运行效果总结主