I'm playing 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 end up with a red element in the shape of the mask image.
The only catch is that I need about 25 different images. I could just load up 25 different mask images, but it'd be great if I could load just one image and then use it akin to a CSS sprite where I reposition it or clip it.
But I can't think of a good way to do that with the mask properties. Is it doable?
The one solution I came up with would be to use markup akin 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 a background image and positioning it as you would a sprite, I'm using a DIV and positioning that within a parent div that crops it. I think that's an OK option, but was wondering if there was a webkit-centric CSS property already designed for exactly this.
-webkit-mask-image
and-webkit-mask-box-image
? – Yester