Skip to content

Commit 2d798ac

Browse files
committed
adding a masking example
1 parent 18f2f87 commit 2d798ac

File tree

2 files changed

+380
-0
lines changed

2 files changed

+380
-0
lines changed

masking/MDN.svg

Lines changed: 242 additions & 0 deletions
Loading

masking/mask-clip.html

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Masking: the mask-clip 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: 260px;
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+
margin: 20px;
68+
border: 20px solid #8ca0ff;
69+
padding: 20px;
70+
-webkit-mask-image: url(./MDN.svg);
71+
-webkit-mask-size: 100% 100%;
72+
-webkit-mask-clip: border-box;
73+
mask-image: url(./MDN.svg);
74+
mask-size: 100% 100%;
75+
mask-clip: border-box;
76+
}
77+
</style>
78+
</head>
79+
80+
<body>
81+
<section>
82+
<div class="masked">
83+
</div>
84+
85+
</section>
86+
87+
<textarea class="playable-css">
88+
.masked {
89+
width: 100px;
90+
height: 100px;
91+
background-color: #8cffa0;
92+
margin: 20px;
93+
border: 20px solid #8ca0ff;
94+
padding: 20px;
95+
-webkit-mask-image: url(./MDN.svg);
96+
-webkit-mask-size: 100% 100%;
97+
-webkit-mask-clip: border-box;
98+
mask-image: url(./MDN.svg);
99+
mask-size: 100% 100%;
100+
mask-clip: border-box;
101+
}
102+
</textarea>
103+
<textarea id="code" class="playable-html">
104+
<div class="masked"></div>
105+
106+
</textarea>
107+
<div class="playable-buttons">
108+
<input id="reset" type="button" value="Reset">
109+
</div>
110+
</body>
111+
<script>
112+
var section = document.querySelector('section');
113+
var editable = document.querySelector('.editable');
114+
var textareaHTML = document.querySelector('.playable-html');
115+
var textareaCSS = document.querySelector('.playable-css');
116+
var reset = document.getElementById('reset');
117+
var htmlCode = textareaHTML.value;
118+
var cssCode = textareaCSS.value;
119+
120+
function fillCode() {
121+
editable.innerHTML = textareaCSS.value;
122+
section.innerHTML = textareaHTML.value;
123+
}
124+
125+
reset.addEventListener('click', function () {
126+
textareaHTML.value = htmlCode;
127+
textareaCSS.value = cssCode;
128+
fillCode();
129+
});
130+
131+
textareaHTML.addEventListener('input', fillCode);
132+
textareaCSS.addEventListener('input', fillCode);
133+
window.addEventListener('load', fillCode);
134+
135+
136+
</script>
137+
138+
</html>

0 commit comments

Comments
 (0)