Skip to content

Commit a938400

Browse files
committed
moving mask-image example here for CORS
1 parent 2d33496 commit a938400

File tree

2 files changed

+159
-0
lines changed

2 files changed

+159
-0
lines changed

masking/mask-image.html

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Masking: the mask-image property</title>
7+
8+
<style>
9+
body {
10+
font: 1.2em Helvetica, Arial, sans-serif;
11+
margin: 20px;
12+
padding: 0;
13+
}
14+
15+
textarea {
16+
font-family: monospace;
17+
display: block;
18+
margin-bottom: 10px;
19+
background-color: #F4F7F8;
20+
border: none;
21+
border-left: 6px solid #558ABB;
22+
color: #4D4E53;
23+
width: 90%;
24+
max-width: 700px;
25+
padding: 10px 10px 0px;
26+
font-size: 90%;
27+
}
28+
29+
textarea:nth-of-type(1) {
30+
height: 200px;
31+
}
32+
33+
textarea:nth-of-type(2) {
34+
height: 100px
35+
}
36+
37+
.playable-buttons {
38+
text-align: right;
39+
width: 90%;
40+
max-width: 700px;
41+
padding: 5px 10px 5px 26px;
42+
font-size: 100%;
43+
}
44+
45+
section {
46+
width: 90%;
47+
max-width: 700px;
48+
border: 1px solid #4D4E53;
49+
border-radius: 2px;
50+
padding: 10px 14px 10px 10px;
51+
margin-bottom: 10px;
52+
}
53+
54+
section input {
55+
display: block;
56+
margin: 5px;
57+
}
58+
59+
60+
61+
</style>
62+
<style class="editable">
63+
.masked {
64+
width: 100px;
65+
height: 100px;
66+
background-color: #8cffa0;
67+
-webkit-mask-image: url(star.svg);
68+
mask-image: url(star.svg);
69+
}
70+
</style>
71+
</head>
72+
73+
<body>
74+
<section>
75+
<div class="masked">
76+
</div>
77+
78+
</section>
79+
80+
<textarea class="playable-css">
81+
.masked {
82+
width: 100px;
83+
height: 100px;
84+
background-color: #8cffa0;
85+
-webkit-mask-image: url(star.svg);
86+
mask-image: url(star.svg);
87+
}
88+
</textarea>
89+
<textarea id="code" class="playable-html">
90+
<div class="masked"></div>
91+
92+
</textarea>
93+
<div class="playable-buttons">
94+
<input id="reset" type="button" value="Reset">
95+
</div>
96+
</body>
97+
<script>
98+
var section = document.querySelector('section');
99+
var editable = document.querySelector('.editable');
100+
var textareaHTML = document.querySelector('.playable-html');
101+
var textareaCSS = document.querySelector('.playable-css');
102+
var reset = document.getElementById('reset');
103+
var htmlCode = textareaHTML.value;
104+
var cssCode = textareaCSS.value;
105+
106+
function fillCode() {
107+
editable.innerHTML = textareaCSS.value;
108+
section.innerHTML = textareaHTML.value;
109+
}
110+
111+
reset.addEventListener('click', function () {
112+
textareaHTML.value = htmlCode;
113+
textareaCSS.value = cssCode;
114+
fillCode();
115+
});
116+
117+
textareaHTML.addEventListener('input', fillCode);
118+
textareaCSS.addEventListener('input', fillCode);
119+
window.addEventListener('load', fillCode);
120+
121+
122+
</script>
123+
124+
</html>

masking/star.svg

+35
Loading

0 commit comments

Comments
 (0)