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

Vue添加图片作为水印

直接上代码

把图片作为水印

<div class="info-warp"><div class="image-container"><img src="https://img.shetu66.com/2023/06/28/1687920981963810.png" /><div class="watermark-layer"><imgv-for="(pos, idx) in watermarkPositions":key="idx":src="watermarkImg":style="{left: pos.x + 'px',top: pos.y + 'px',opacity: 0.4,width: watermarkWidth + 'px',height: 'auto',position: 'absolute',transform: 'rotate(-20deg)',pointerEvents: 'none',}"/></div></div></div>
computed: {watermarkPositions() {const containerW = 800;const containerH = 1492; // info-warp高度const arr = [];for (let y = 0; y < containerH; y += this.watermarkHeight + this.watermarkGapY) {for (let x = 0; x < containerW; x += this.watermarkWidth + this.watermarkGapX) {arr.push({ x, y });}}return arr;},},// 水印watermarkImg:'https://images.pexels.com/photos/6131296/pexels-photo-6131296.jpeg?cs=srgb&dl=pexels-quang-nguyen-vinh-6131296.jpg&fm=jpg',watermarkGapX: 60, // 横向间距watermarkGapY: 60, // 纵向间距watermarkWidth: 120, // logo宽度watermarkHeight: 43, // logo高度(按实际比例)<style lang="scss" scoped>
.info-warp {width: 800px;height: 1492px;.image-container {position: relative;width: 100%;height: 90%;overflow: hidden;img {width: 100%;height: 100%;border-radius: 12px;box-shadow: 0px 5.07px 38.05px 0px rgba(0, 0, 0, 0.3);}.watermark-layer {position: absolute;top: 0;left: 0;width: 100%;height: 100%;pointer-events: none;z-index: 1;}}
}
</style>

替换掉里面的示例图片即可

http://www.xdnf.cn/news/14707.html

相关文章:

  • Vue.js 按键修饰符详解:提升键盘事件处理效率
  • AndroidView的简单使用
  • 【AI Study】第四天,Pandas(6)- 性能优化
  • 配置外设参数与时钟频率 (PCLK1, PCLK2) 的关系
  • vue3 javascript 复杂数值计算操作技巧
  • 一个简单的图书馆管理系统
  • web和uniapp接入腾讯云直播
  • 意法STM32F103C8T6 单片机ARM Cortex-M3 国民MCU 电机控制到物联网专用
  • 《HTTP权威指南》 第1-2章 HTTP和URL基础
  • ArkUI-X跨平台技术落地-华为运动健康(二)
  • 要在 Linux 不联网服务器 上部署并运行 Gitee 上的 vue-vben-admin 项目,并且该项目使用的是 pnpm 管理依赖
  • pythonday50
  • Cornerstone3D 2.x升级调研
  • RK3568笔记八十三:RTMP推流H264和PCM
  • 技术与情感交织的一生 (八)
  • SpringBoot自动化部署全攻略:从Shell脚本到云原生实践
  • WebRTC(六):ICE协议
  • 爬虫技术:数据挖掘的深度探索与实践应用
  • Appium入门
  • SonarQube 25.6 完整指南:部署、使用与 CI/CD 集成
  • CppCon 2016 学习:The Exception Situation
  • 6.IK分词器拓展词库
  • AI智能体应用市场趋势分析
  • WinForms视频播放开发实战指南
  • 【数据库】在线体验KingbaseES平台,零门槛学习,并快速体验Oracle增改查全基础功能
  • python web开发-Flask 重定向与URL生成完全指南
  • 代码随想录打卡第三十天 动态规划
  • 论文笔记 <交通灯> IntelliLight:一种用于智能交通灯控制的强化学习方法
  • 性能测试|数据说话!在SimForge平台上用OpenRadioss进行汽车碰撞仿真,究竟多省时?
  • 物联网传输网关、RTU、DTU及SCADA系统技术解析