jQuery: there is a way to apply colour (tint) to an image?

前端 未结 4 1841
长发绾君心
长发绾君心 2020-11-29 12:33

there is a way to colour (apply tint) an image using jQ or some plugs? thank you

4条回答
  •  一整个雨季
    2020-11-29 12:47

    Simplest way I can think of is overlaying a semitransparent div over the image.

    A little example:

    HTML

    CSS

    .overlay
        {
        display: block;
        position: absolute;
        background-color: rgba(200, 100, 100, 0.5);
        top: 0px;
        left: 0px;
        width: 0px;
        height: 0px;
        }
    

    JS (with JQuery)

    overlay = $("#overlay");
    img = $("#myimg");
    overlay.width(img.css("width"));
    overlay.height(img.css("height"));
    overlay.css("top", img.offset().top + "px");
    overlay.css("left", img.offset().left + "px");
    

提交回复
热议问题