Skip to content

Instantly share code, notes, and snippets.

@spencern
Last active September 20, 2016 00:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spencern/6016019 to your computer and use it in GitHub Desktop.
Save spencern/6016019 to your computer and use it in GitHub Desktop.
Creating Image Masks with SVG and CSS
.circle {
-webkit-border-radius: 1000px;
-moz-border-radius: 1000px;
border-radius: 1000px;
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
.logo-mask {
/* *** For Firefox use mask *** */
/* *** Note that we use an ID selector here #logo_mask *** */
/* *** which is the same as the ID we defined in the SVG mask *** */
mask: url("img/masks/logo.svg#logo_mask");
/* *** For webkit use -webkit-mask-image *** */
-webkit-mask-image: url("img/masks/logo.svg");
width: 300px;
height: 300px;
}
<img class="logo-mask" src="yobelmarket.jpg" /><!-- Square Image -->
<img class="logo-mask" src="yobel-thumb.jpg" /><!-- Rectangular Image -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment