小编joh*_*ohn的帖子

为什么 html2canvas 顶部有一个空白区域?

我的有一个空白区域,我html2canvas不确定发生了什么。到目前为止,这是我的代码。

function doFunction() {

  html2canvas(document.querySelector("#capture"), ).then(canvas => {
    $("body").append(canvas);
  });
}

$("button").click(function() {
  doFunction();
});
Run Code Online (Sandbox Code Playgroud)
div {
  box-sizing: border-box;
  font-family: 'ABeeZee', sans-serif;
}

body {
  background-color: red;
}

#capture {
  width: 900px;
  height: 900px;
  background-color: aqua;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<div id="capture">
  Hello
</div>
<button type="button">Click Me!</button>
Run Code Online (Sandbox Code Playgroud)

这是附加的画布。请注意,顶部有一个空白区域。我怎样才能删除它?

在此处输入图片说明

html javascript css html2canvas

20
推荐指数
1
解决办法
6736
查看次数

标签 统计

css ×1

html ×1

html2canvas ×1

javascript ×1