以画布为中心 [英] Centering a canvas
本文介绍了以画布为中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用HTML5 画布
标记页面,使画布
How do I markup a page with an HTML5 canvas
such that the canvas
-
占据宽度的80%
Takes up 80% of the width
纵向和横向居中
您可以假设 canvas
是页面上唯一的东西,
You can assume that the canvas
is the only thing on the page, but feel free to encapsulate it in div
s if necessary.
推荐答案
这将集中在 div 水平画布:
#canvas-container {
width: 100%;
text-align:center;
}
canvas {
display: inline;
}
HTML:
HTML:
<div id="canvas-container">
<canvas>Your browser doesn't support canvas</canvas>
</div>
这篇关于以画布为中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文