开发者

How to set a percent as width of an image in Jquery (black and white plugin)

开发者 https://www.devze.com 2023-03-25 02:11 出处:网络
I\'m using this plugin: http://plugins.jquery.com/project/BlackAndWhite But I can\'t seem to figure out how to set the width of the images in percent.

I'm using this plugin: http://plugins.jquery.com/project/BlackAndWhite

But I can't seem to figure out how to set the width of the images in percent.

Here's the thing. On the original (colored) image, I use width: 80%, but on the black/white image I can'开发者_运维百科t seem to figure out how to change the width to 80%. In the plugin jquery.BlackAndWhite file I found this part of the code (line 59)

imageData = ctx.getImageData(0, 0, width, height);

I tried to change the width to

imageData = ctx.getImageData(0, 0, width=80, height);

And that works.. Only I get an image of 40 pixels. And it didn't scale the image. When I use this:

imageData = ctx.getImageData(0, 0, width=80%, height);

The code doesn't recognize the '%' symbol. Anyone has any clue how I can fix this? Thanks in advance!


Better is to set this image inside container width 80%; and then inside this container image width to 100%; then both black and color image grab 80% width;

#imagecontainer{width:80%;height:80%;}
#imagecontainer img {width:100%;height:100%;}

As both original and gray cloned image gets the same 80% width hold by their container;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号