画布默认大小 [英] canvas default size

查看:166
本文介绍了画布默认大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Chrome似乎会将canvas标签的默认宽度设置为300像素。

Chrome seems to set canvas tags a default width of 300px.

这是一个有点麻烦,当我想要一个画布默认为它的大小div。

This is a bit of a nuisance when I want a canvas to default to the size of it's containing div, which has an unspecified size.

使用范例这里 ,我想画布默认为添加填充的标题的宽度。

Using the example here, I'd like the canvas to default to the width of the heading with added padding.

希望有意义。

这是否可能没有javascript?

Is this possible without javascript?

推荐答案

Finnnn,你是对的。

Finnnn, you are right.


http:// www.w3.org/TR/2012/WD-html5-author-20120329/the-canvas-element.html#the-canvas-element

canvas元素有两个属性来控制坐标空间的大小:width和height。

The canvas element has two attributes to control the size of the coordinate space: width and height.

这些属性在指定时必须具有有效的非负整数值。

These attributes, when specified, must have values that are valid non-negative integers.

默认为 300 ,height属性默认为 150

The width attribute defaults to 300, and the height attribute defaults to 150.

这篇关于画布默认大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆