【发布时间】:2019-11-30 10:43:05
【问题描述】:
我有以下示例情况:
(图片内有3个球)
使用 jquery jquery 或 css,我想切割黄色球,然后改变它的大小(宽度和高度)。等等我想要的球
我在帖子中看到了一个方法:Programmatically Clip/Cut image using Javascript。但是我正在失去图像质量并且无法更改高度或宽度
这是我的代码:
function setViewport(img, x, y, width, height) {
if (!img) {
return;
}
img.style.left = "-" + x + "px";
img.style.top = "-" + y + "px";
if (width !== undefined) {
img.parentNode.style.width = width + "px";
img.parentNode.style.height = height + "px";
}
}
【问题讨论】:
标签: javascript jquery css