首页 > 开发 > HTML > 正文

为什么结果会向下移了10px

2017-09-09 13:44:34  来源: 网友分享

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>practice</title>
<style>

body{background:black}#cvs{background:white}

</style>
<script>
window.onload=function(){

var oCvs=document.getElementById("cvs");var oGc=oCvs.getContext("2d");  oGc.font="60px impact";oGc.textBaseline="top";oGc.fillText("妙味课堂",0,0);    

}
</script>
</head>
<body>

<canvas id="cvs" width="400px" height="400px"></canvas>

</body>
</html>

解决方案

oGc.textBaseline="hanging";