vue使用html2Canvas导出图片 input文字向上偏移

vue使用html2Canvas导出图片 input文字向上偏移

图中 用的是element的输入框 行高 32px,经常测试 你使用原生的input 还是会出现偏移。

解决方法:修改css样式

1.怎么实现导出 网上随便找很多

2.在第一步 获取你要导出的元素id 克隆后 修改他的样式或者 你直接在你需要打印的页面全局修改样式

3.主要是重置字体的行高,我这里输入框高度是32px 固定的 ,那就使用line-height 和 padding-top 来让他文字居中

复制代码
const cloneDom = document.getElementById(content).cloneNode(true)
        document.getElementsByTagName('body')[0].appendChild(cloneDom)
        cloneDom.querySelectorAll('input').forEach(input => {
          input.style.height = '32px'
          input.style.lineHeight = '14px'
          input.style.paddingTop = '6px'
        })

效果 差不多 能居中了 完美解决

相关推荐
摘星编程1 天前
OpenHarmony + RN:Placeholder文本占位
javascript·react native·react.js
a1117761 天前
医院挂号预约系统(开源 Fastapi+vue2)
前端·vue.js·python·html5·fastapi
0思必得01 天前
[Web自动化] Selenium处理iframe和frame
前端·爬虫·python·selenium·自动化·web自动化
计算机毕设VX:Fegn08951 天前
计算机毕业设计|基于springboot + vue蛋糕店管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
行走的陀螺仪1 天前
uni-app + Vue3编辑页/新增页面给列表页传参
前端·vue.js·uni-app
摘星编程1 天前
React Native + OpenHarmony:Spinner旋转加载器
javascript·react native·react.js
We་ct1 天前
LeetCode 205. 同构字符串:解题思路+代码优化全解析
前端·算法·leetcode·typescript
2301_812731411 天前
CSS3笔记
前端·笔记·css3
ziblog1 天前
CSS3白云飘动动画特效
前端·css·css3
越努力越幸运5081 天前
CSS3学习之网格布局grid
前端·学习·css3