Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html2canvas 使用笔记 #23

Open
zp1112 opened this issue Sep 26, 2018 · 0 comments
Open

html2canvas 使用笔记 #23

zp1112 opened this issue Sep 26, 2018 · 0 comments

Comments

@zp1112
Copy link
Owner

zp1112 commented Sep 26, 2018

字体大小无法正常转化问题

查询了html2canvas的issue,发现原因是因为字体设置了 font-variant: tabular-nums,于是在代码中查找该属性,并没有,然而在浏览器中查找到了该属性,原来是antd的样式里面有这个设置,至于font-variant是干啥的,字体研究太深奥了,不管他。
在body中设置font-variant为normal就ok了,同时也解决了字符错位问题。

截图有白边问题

由于传入的width和height使用了clientWidth取值,默认是取整的,因此白边的产生就是实际元素多出来的小数点。使用target.getBoundingClientRect().width.toFixed(2)替换clientWidth,因为元素默认保留后两位,所以fixed2,但是还有问题,因为这样得到的不是数值,是字符串,无法生效,因此在前面加个+使之变成数字即可。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant