<!--
* @Author: hhn
* @Date: 2020-03-14 17:26:03
* @lastEditTime: Do not edit
* @Description: In User Settings Edit
* @FilePath: \codehub\study\studying\html\canva.html
-->
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HTML5</title>
<link href="https://fonts.googleapis.com/css?family=Lato:400,400i|Roboto:500" rel="stylesheet">
<!-- 为 Internet Explorer 支持而添加的 shiv -->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
body {
margin: 0;
}
</style>
<body>
<canvas id="myCanvas" width="200" height="100">
<p>如果浏览器支持Canvas,它将忽略canvas内部的HTML,如果浏览器不支持Canvas,它将显示canvas内部的HTML</p>
</canvas>
</body>
<script>
var canva = document.getElementById("myCanvas");
if (canva.getContext) {
console.log('你的浏览器支持Canvas!');
var ctx = canva.getContext("2d");
ctx.fillStyle = "#dddddd";
ctx.fillRect(10, 10, 150, 150);
ctx.shadowOffsetX = 2;
ctx.shadowOffsetY = 2;
ctx.shadowBlur = 2;
ctx.shadowColor = '#666666';
ctx.font = '24px Arial';
ctx.fillStyle = '#333333';
ctx.fillText('带阴影的文字', 20, 40);
} else {
console.log('你的浏览器不支持Canvas!');
}
var k;
console.log(k)
</script>
</html>