<canvas width="800" height="600" id="can" οnclick="img_click(this)"></canvas> //800px ,加不加单位都是可以的
一个页面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>canvas_font</title>
<style type="text/css">
body{margin:20px auto; padding:0; width:800px; }
canvas{border:dashed 2px #CCC}
</style>
<script type="text/javascript">
function getId(id){
return document.getElementById(id);
}
function pageLoad(){
var can= getId('can');
var cans=can.getContext('2d');
console.log(cans);
cans.font="bold 144px consolas"; //和css font属性相同,可以不写全,顺序不要颠倒 粗细、大小、字体
cans.textAlign="left"; //这个比较难理解,参考下文textAlign
cans.textBaseline="top&#