canvas的width和style里面的width
来源:互联网 发布:go高级编程书籍 编辑:程序博客网 时间:2024/05/24 06:54
在w3网站上是这样解释的:
The
canvas
element has two attributes to control the size of the coordinate space:width
andheight
. These attributes, when specified, must have values that are valid non-negative integers. The rules for parsing non-negative integers must be used to obtain their numeric values. If an attribute is missing, or if parsing its value returns an error, then the default value must be used instead. Thewidth
attribute defaults to 300, and theheight
attribute defaults to 150.The intrinsic dimensions of the
canvas
element equal the size of the coordinate space, with the numbers interpreted in CSS pixels. However, the element can be sized arbitrarily by a style sheet. During rendering, the image is scaled to fit this layout size.
其实这里已经说的很明白,通俗点说就是在canvas中定义width、height跟在style中定义width和height是不同的,canvas标签的width和height是画布实际宽度和高度,绘制的图形都是在这个上面。而style的width和height是canvas在浏览器中被渲染的高度和宽度。如果canvas的width和height没指定或值不正确,就被设置成默认值(width:300px,height:150px)。
我们可以利用style的width和height来缩放canvas,请看下面的示例。
- canvas的width和style里面的width
- canvas标签的width和height以及style.width和style.height的区别
- canvas标签的width和height以及style.width和style.height的区别
- canvas标签的width和height以及style.width和style.height的区别
- HTML5 Canvas 的width/height 与style.width/height
- js的style.width和offsetWidth问题
- offsetWidth和style.width的区别
- jQuery--.css("width")和.width()的区别
- width:auto和width:100%的区别
- width:auto和width:100%的区别
- width:auto和width:100%的区别
- 关于`width`和`max-width`的故事
- getMeasureHight(Width)和getHight(Width)的区别
- 详解 $().css('width')和$().width()的区别
- canvas的width和height属性的特殊之处
- Html canvas的width、height与在style中设置宽高的区别
- Canvas设置width与height 的问题!
- style.width和offsetwidth区别
- [并行计算] 1. 并行计算简介
- 类型转化
- Spring 开启Annotation <context:annotation-config> 和 <context:component-scan>诠释及区别
- GitBash的安装和使用
- SQL1999语法
- canvas的width和style里面的width
- Session
- maven项目中hibernate创建步骤
- php编程初识
- BZOJ2821: 作诗(Poetize)(分块)
- .Java多分支;if……else…… 每吨货物每公里运费P与运输距离S有关,路途越远,每公里运价越低。两种解决方案
- QT help button 和 setWhatsThis
- 图解集合8:红黑树的移除节点操作
- First Position Unique Character