CSS or JavaScript to highlight certain area of image opacity

前端 未结 5 1816
攒了一身酷
攒了一身酷 2021-01-14 14:46

I\'m looking to do something like this but with CSS or JavaScript.

I need to highlight a certain part of an image but everything I find is how to do it in Photoshop.

5条回答
  •  梦毁少年i
    2021-01-14 14:49

    These are the steps you can take to highlight a part of an image:

    1. Access the image in JavaScript, and dynamically add another identical image immediately after it. (this could be done just in HTML, but it would change the semantics of your markup)
    2. Position the second image over the first image
    3. Apply a css mask on the second image so that only the "highlighted" part shows up
    4. When the user hovers over the images' container, adjust the opacity of the first image.

    I can provide more technical details on this later if need be.

提交回复
热议问题