Scenario: I want to cover an element by a rectangular mask (background #000 with opacity 0.8, for example). Next, there’s an area in the covered area for which I want to highlight.
Here is a sample screenshot:
(As you notice, there’ s a rectangle cut from the darken mask. In Photoshop, it’s easy – just place a layer on top and cut the rectangle out).
How could I make it work in CSS?
Side note: This kind of trick seems to be used a lot for “educating users about new features”.
3
Answers
This Can be done only in webkit at the moment. using the property
-webkit-mask-box-image
. other than that we can’t achieve this only using css.You could use border or box-shadows for this. And use them on a pseudo element to minimize markup.
Example with box-shadows :
You can use CSS
z-index
to display the highlighted element above the overlay like this:Live Demo