I play with the -webkit-mask-box-image css property.
<div style=" background-color: red; -webkit-mask-box-image: url('images/cards/set1.png'); "></div>
This works great. I get a red element in the form of a mask image.
The only catch is that I need about 25 different images. I could just upload 25 different mask images, but it would be great if I could only upload one image and then use it, similar to a CSS sprite, where I rearrange it or clip.
But I can't think of a good way to do this using mask properties. Is this doable?
The only solution I came across is to use markup similar to this:
<div style=" width: 100px; height: 100px; overflow: hidden; position: relative;"> <div style=" background-color: red; -webkit-mask-box-image: url('images/cards/set1.png'); position: absolute; top: -400px "></div> </div>
Instead of using the background image and positioning it in the same way as the sprite, I use the DIV and positioning, which is in the parent div that crop it. I think the option is OK, but I wondered if there was already a webkit-based CSS property already set up just for that.
source share