zii*_*web 2 html javascript css jquery
如何在这里修改图像的大小?:
var image = new Image();
image.src = 'http://www.ziiweb.com/images/logo.png';
image.width = 200; //this is not modifying the width of the image
$('canvas').css({
background: 'url(' + image.src + ')'
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">
</canvas>Run Code Online (Sandbox Code Playgroud)
您将图像作为背景插入,因此请使用背景大小.
var image = new Image();
image.src = 'http://www.ziiweb.com/images/logo.png';
$('canvas').css({
backgroundImage: 'url(' + image.src + ')',
backgroundSize: "100%"
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">
</canvas>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
56 次 |
| 最近记录: |