简体   繁体   中英

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

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM