本文主要是介绍canvas_font,基础,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<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&#
这篇关于canvas_font,基础的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!