无法居中对齐画布 [英] cannot center align canvas
本文介绍了无法居中对齐画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
center-align
我的画布
。 我试过
float =center
, text-align =center
, margin-top:100px
但我的舞台没有在浏览器中对齐中心。
任何帮助表示赞赏。
< body onLoad =Main();>
< canvas id =Shooterwidth =320height =480align =center>
您的浏览器不支持HTML5画布标签。
< / canvas>
解决方案
#Shooter {
margin:auto;
display:block;
}
确保父容器的宽度为100%。
这是一支钢笔。
http://codepen.io/asim-coder/pen/aNpWoB
I Have been googling for solutions to no avail. I just want to center-align
my canvas
.
I have tried float="center"
, text-align="center"
, margin-top: 100px
but my stage didnt align center in the browser.
Any help is appreciated.
<body onLoad="Main();">
<canvas id="Shooter" width="320" height="480" align="center">
Your browser does not support the HTML5 canvas tag.
</canvas>
解决方案
You could center align it by:
#Shooter {
margin: auto;
display: block;
}
Make sure the parent container have 100% width.
Here's a pen. http://codepen.io/asim-coder/pen/aNpWoB
这篇关于无法居中对齐画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文