如何在 Jquery 中设置图像宽度的百分比(黑白插件)
我正在使用这个插件: http://plugins.jquery.com/project/BlackAndWhite
但是我似乎不知道如何以百分比设置图像的宽度。
事情是这样的。在原始(彩色)图像上,我使用 width: 80%
,但在黑白图像上我似乎不知道如何将宽度更改为 80%。在插件 jquery.BlackAndWhite 文件中,我找到了这部分代码(第 59 行),
imageData = ctx.getImageData(0, 0, width, height);
我尝试将宽度更改为
imageData = ctx.getImageData(0, 0, width=80, height);
并且有效。只有我得到了 40 像素的图像。而且它没有缩放图像。当我使用它时:
imageData = ctx.getImageData(0, 0, width=80%, height);
代码无法识别“%”符号。有人知道我该如何解决这个问题吗? 提前致谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更好的办法是将此图像设置在容器宽度 80% 内;然后把这个容器里面的图片宽度调到100%;然后黑色和彩色图像都占据 80% 的宽度;
由于原始图像和灰色克隆图像的容器都具有相同的 80% 宽度;
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;
As both original and gray cloned image gets the same 80% width hold by their container;