html2canvas 在错误位置渲染固定元素

发布于 2025-01-10 20:25:13 字数 88 浏览 2 评论 0原文

当我在具有固定标题的页面上使用 html2canvas 时,它会将标题呈现在画布底部附近,而不是应位于顶部的位置。是否有解决方法,以便将固定元素呈现在正确的位置?

When I use html2canvas on a page with a fixed header, it renders the header near the bottom of the canvas rather than where it should be at the top. Is there a workaround for this so that it renders fixed elements in the correct position?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朦胧时间 2025-01-17 20:25:13

如果没有看到您的代码,您可能需要指定 标题的子元素的vertical-align属性text-top

Without seeing your code, it is possible that you need to specify the vertical-align property of the header's children elements to be text-top.

贵在坚持 2025-01-17 20:25:13

将scrollX和scrollY设置为0可以解决这个问题。

 html2canvas(document.body,{scrollX: 0, scrollY: 0})

Setting scrollX and scrollY to 0 sorted the issue.

 html2canvas(document.body,{scrollX: 0, scrollY: 0})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文