Skip to content

Commit

Permalink
moving mask-image example here for CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelandrew committed Feb 8, 2021
1 parent 2d33496 commit a938400
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 0 deletions.
124 changes: 124 additions & 0 deletions masking/mask-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>Masking: the mask-image property</title>

<style>
body {
font: 1.2em Helvetica, Arial, sans-serif;
margin: 20px;
padding: 0;
}

textarea {
font-family: monospace;
display: block;
margin-bottom: 10px;
background-color: #F4F7F8;
border: none;
border-left: 6px solid #558ABB;
color: #4D4E53;
width: 90%;
max-width: 700px;
padding: 10px 10px 0px;
font-size: 90%;
}

textarea:nth-of-type(1) {
height: 200px;
}

textarea:nth-of-type(2) {
height: 100px
}

.playable-buttons {
text-align: right;
width: 90%;
max-width: 700px;
padding: 5px 10px 5px 26px;
font-size: 100%;
}

section {
width: 90%;
max-width: 700px;
border: 1px solid #4D4E53;
border-radius: 2px;
padding: 10px 14px 10px 10px;
margin-bottom: 10px;
}

section input {
display: block;
margin: 5px;
}



</style>
<style class="editable">
.masked {
width: 100px;
height: 100px;
background-color: #8cffa0;
-webkit-mask-image: url(star.svg);
mask-image: url(star.svg);
}
</style>
</head>

<body>
<section>
<div class="masked">
</div>

</section>

<textarea class="playable-css">
.masked {
width: 100px;
height: 100px;
background-color: #8cffa0;
-webkit-mask-image: url(star.svg);
mask-image: url(star.svg);
}
</textarea>
<textarea id="code" class="playable-html">
<div class="masked"></div>

</textarea>
<div class="playable-buttons">
<input id="reset" type="button" value="Reset">
</div>
</body>
<script>
var section = document.querySelector('section');
var editable = document.querySelector('.editable');
var textareaHTML = document.querySelector('.playable-html');
var textareaCSS = document.querySelector('.playable-css');
var reset = document.getElementById('reset');
var htmlCode = textareaHTML.value;
var cssCode = textareaCSS.value;

function fillCode() {
editable.innerHTML = textareaCSS.value;
section.innerHTML = textareaHTML.value;
}

reset.addEventListener('click', function () {
textareaHTML.value = htmlCode;
textareaCSS.value = cssCode;
fillCode();
});

textareaHTML.addEventListener('input', fillCode);
textareaCSS.addEventListener('input', fillCode);
window.addEventListener('load', fillCode);


</script>

</html>
35 changes: 35 additions & 0 deletions masking/star.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a938400

Please sign in to comment.