Skip to content

Commit 8350855

Browse files
committed
CSS blending and compositing example
1 parent 7999b0b commit 8350855

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

modules/compositing.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!DOCTYPE html>
2+
<html lang="en-us">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width" />
6+
<title>CSS blending and compositing sample</title>
7+
<style>
8+
/* creates a div with two offset striped background images and a background color. */
9+
div {
10+
width: 200px;
11+
height: 200px;
12+
background-image:
13+
repeating-linear-gradient(45deg, red 0 15px, pink 15px 30px),
14+
repeating-linear-gradient(-45deg, blue 0 15px, lightblue 15px 30px);
15+
background-size: 150px 150px;
16+
background-repeat: no-repeat;
17+
background-position: top left, bottom right;
18+
background-color: palegoldenrod;
19+
text-align: center;
20+
padding-top: 150px;
21+
font-family: sans-serif;
22+
box-sizing: border-box;
23+
border: 5px solid black;
24+
}
25+
div:nth-of-type(3n+1){
26+
background-blend-mode: normal;
27+
}
28+
div:nth-of-type(3n+2){
29+
background-blend-mode: multiply;
30+
}
31+
div:nth-of-type(3n+3){
32+
background-blend-mode: overlay;
33+
}
34+
div:nth-of-type(n + 4) {
35+
mix-blend-mode: difference;
36+
}
37+
/* put a pink background with transparent round holes that covers the entire element, and lay the examples in two rows with three columns each */
38+
section {
39+
padding: 0.75em;
40+
background: radial-gradient(circle, transparent 0 20px, rgb(255, 200, 200) 20px);
41+
background-size: 60px 60px;
42+
background-position: center;
43+
display: inline-grid;
44+
grid-template-columns: 1fr 1fr 1fr;
45+
gap: 1em;
46+
}
47+
/* make some of the text more legible */
48+
span {
49+
background-color: #ffffff99;
50+
}
51+
</style>
52+
</head>
53+
<body>
54+
<section>
55+
<div><span>Normal, with no blending</span></div>
56+
<div><span>Multiplies colors</span></div>
57+
<div><span>Multiplies based on background color</span></div>
58+
<div>Normal, with no blending</div>
59+
<div>Multiplies colors</div>
60+
<div>Multiplies based on background color</div>
61+
</section>
62+
</body>
63+
</html>

0 commit comments

Comments
 (0)