jQuery - 如何使图像变亮

Cha*_*ung 3 css jquery


在jQuery中,我们可以使用如下代码,使图像变暗.相反,我们怎样才能使图像变亮?

$(this).hover(function() {
    $(this).stop().animate({ opacity: 0.5 }, 500);
},
function() {
    $(this).stop().animate({ opacity: 1.0 }, 500);
});
Run Code Online (Sandbox Code Playgroud)

Mat*_*all 7

我会使用Pixastic.如果你想采用那条路线,它有jQuery绑定.

您可以像这样使图像变亮或变暗:

var img = new Image();
img.onload = function() {
    Pixastic.process(img, "lighten", {amount:0.5});
}
document.body.appendChild(img);
img.src = "myimage.jpg";
Run Code Online (Sandbox Code Playgroud)

您可以通过更改图像的不透明度来伪造此效果,确保图像背后的背景为白色.