' + title + "";
19 |
20 | code.value = pattern.getAttribute("style");
21 | code.setAttribute("wrap", "off");
22 |
23 | code.addEventListener("input", function(evt) {
24 | var byteSize = this.parentNode.querySelector(".bytesize");
25 |
26 | if (byteSize) {
27 | byteSize.innerHTML = ByteSize.format(ByteSize.count(this.value), true);
28 | }
29 |
30 | pattern.setAttribute("style", this.value);
31 |
32 | if (currentPattern === pattern) {
33 | // A pattern is opened
34 | document.body.setAttribute("style", this.value);
35 | }
36 |
37 | code.style.setProperty("--lines", this.value.trim().split(/\r?\n|\r/).length);
38 | });
39 |
40 | close.className = "close";
41 | close.href = "#";
42 | close.innerHTML = "✖";
43 |
44 | if (window.ByteSize) {
45 | heading.innerHTML += ' (' + ByteSize.format(ByteSize.count(code.value), true) + ") ";
46 | }
47 |
48 | var author = pattern.getAttribute("data-author");
49 | if (author) {
50 | var p = div.appendChild(document.createElement("p")),
51 | authorUrl = pattern.getAttribute("data-author-url");
52 | p.innerHTML = "by " + (authorUrl? '' + author + " " : author);
53 | }
54 |
55 | div.appendChild(code);
56 |
57 | pattern.appendChild(div);
58 |
59 | pattern.onclick = function(evt) {
60 | // Firefox has focus issues if we don't restrict this
61 | if (!/textarea/i.test(evt.target.nodeName)) {
62 | location.hash = "#" + this.id;
63 | }
64 | };
65 |
66 | window.Incrementable && new Incrementable(code);
67 |
68 | code.dispatchEvent(new InputEvent("input"));
69 | }
70 |
71 | (onhashchange = function() {
72 | var pattern = location.hash? document.querySelector("#patterns li" + location.hash) : null;
73 |
74 | if (pattern) {
75 | recentPattern = currentPattern = pattern;
76 | document.body.setAttribute("style", pattern.getAttribute("style"));
77 | }
78 | else {
79 | currentPattern = null;
80 | document.body.removeAttribute("style");
81 | }
82 | })();
83 |
84 | })();
85 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | CSS3 Patterns Gallery
7 |
8 |
9 |
10 |
11 |
12 | CSS3 Patterns Gallery
13 |
14 |
15 |
16 |
24 |
25 |
30 |
31 |
37 |
38 |
46 |
47 |
53 |
54 |
61 |
62 |
67 |
68 |
81 |
82 |
90 |
91 |
97 |
98 |
109 |
110 |
119 |
120 |
127 |
128 |
142 |
143 |
150 |
151 |
166 |
167 |
172 |
173 |
180 |
191 |
192 |
209 |
210 |
216 |
217 |
222 |
223 |
231 |
232 |
240 |
241 |
250 |
251 |
256 |
257 |
264 |
265 |
270 |
271 |
275 |
276 |
281 |
282 |
297 |
298 |
303 |
304 |
311 |
312 |
316 |
317 |
319 |
320 |
326 |
327 |
330 |
331 |
334 |
335 |
336 |
337 |
346 |
347 |
354 |
355 |
361 |
362 |
367 |
368 |
378 |
379 |
380 |
381 | Browser support
382 | The patterns themselves should work on Firefox 3.6+ , Chrome , Safari 5.1 , Opera 11.10+ and IE10+ .
383 | However, implementation limitations might cause some of them to not be displayed correctly even on those browsers (for example at the time of writing, Gecko is quite buggy with radial gradients).
384 | Also, this gallery won’t work in Firefox 3.6 and IE10, even though they support gradients, due to a JavaScript limitation.
385 |
386 | Submission guidelines
387 | If you have a new pattern to submit, please send a pull request . However, please bear in mind that I can't accept all submissions, sorry for that. For a pattern to be accepted, the following factors are considered (in descending order of importance):
388 |
389 | Does it present a new technique?
390 | Is the number of gradients and color stops worth the effect? The whole point of those patterns is to make page loading faster by reducing file size and HTTP requests without the unreadable gibberish that data URIs add in our stylesheets. If your pattern needs a 2KB code for example (which becomes 10KB when used in production, due to all the prefixes), then it's not very useful, except serving as a proof of concept.
391 | How common is the pattern?
392 | Does it look nice?
393 |
394 |
395 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
411 |
412 |
413 |
414 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 Lea Verou, http://lea.verou.me/
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/noise.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeaVerou/css3patterns/98adf4d231ee9f50be2b9713cbb210606385732f/noise.png
--------------------------------------------------------------------------------
/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin:0;
3 | padding:0;
4 | }
5 |
6 | html {
7 | height:100%;
8 | }
9 |
10 | body {
11 | min-height:100%;
12 | padding:0 2.5em;
13 | font-family: Palatino, 'Palatino Linotype', serif;
14 | background: #e8eff5 url('noise.png');
15 | box-sizing: border-box;
16 | }
17 |
18 | h1, h2 {
19 | padding-top:.2em;
20 | color:#e50;
21 | text-shadow: 0 2px white;
22 | }
23 |
24 | h1 {
25 | text-align:center;
26 | font-size:500%;
27 | }
28 |
29 | a {
30 | color:inherit;
31 | text-decoration:none;
32 | }
33 |
34 | body > p,
35 | body > ul {
36 | margin:1em 0;
37 | line-height:1.5;
38 | }
39 |
40 | h2,
41 | p,
42 | ul:not(#patterns) {
43 | text-shadow: 0 1px white;
44 | }
45 |
46 | body[style] > h2,
47 | body[style] > p,
48 | body[style] > ul:not(#patterns) {
49 | display:none;
50 | }
51 |
52 | h2 + p,
53 | p + ul {
54 | margin-top:.3em;
55 | }
56 |
57 | body > ul > li > a,
58 | body > p > a {
59 | border-bottom:2px dotted white;
60 | }
61 |
62 | body > ul > li > a:hover,
63 | body > p > a:hover {
64 | border-bottom-color:slategray;
65 | }
66 |
67 | #help {
68 | text-align: center;
69 | }
70 |
71 | #help > li {
72 | display:inline;
73 | list-style:none;
74 | text-shadow: 0 1px white;
75 | }
76 |
77 | #help > li + li:before {
78 | content: '● ';
79 | opacity:.4;
80 | }
81 |
82 | #patterns {
83 |
84 | }
85 |
86 | #patterns:after {
87 | content:"";
88 | display:block;
89 | clear:both;
90 | }
91 |
92 | #patterns > li {
93 | position:relative;
94 | width: 300px;
95 | height:300px;
96 | margin:40px;
97 | float:left;
98 | list-style:none;
99 | }
100 |
101 | #patterns > li:not(:target) {
102 | cursor:pointer;
103 | background-color:gray;
104 | border-radius: 150px;
105 | box-shadow: -3px -3px 10px 2px rgba(0,0,0,.3) inset,
106 | 0 0 0 15px rgba(255, 255, 255, .6) inset,
107 | 0 0 0 1px rgba(0,0,0,.5),
108 | 2px 2px 10px rgba(0,0,0,.6);
109 | /* Overrride for Webkit bug */
110 | -webkit-box-shadow: 0 0 0 15px rgba(255, 255, 255, .6) inset,
111 | 0 0 0 1px rgba(0,0,0,.5),
112 | 2px 2px 10px rgba(0,0,0,.6);
113 | }
114 |
115 | #patterns > li:target {
116 | background: none !important;
117 | }
118 |
119 | body[style] #patterns > li:not(:target) {
120 | display:none;
121 | }
122 |
123 | #patterns > li > div {
124 | position:absolute;
125 | top:235px;
126 | left:55px;
127 | width:250px;
128 | z-index:2;
129 | padding:3px 10px 5px;
130 | color:#e50;
131 | color: hsla(20,100%,50%,.94);
132 | font-size:90%;
133 | background:currentColor;
134 | box-shadow: 2px 2px 10px rgba(0,0,0,.5);
135 | }
136 |
137 | #patterns > li:target > div {
138 | position:fixed;
139 | top:auto;
140 | left:20px;
141 | right:20px;
142 | bottom:20px;
143 | z-index:3;
144 | width:auto;
145 | padding:10px;
146 | font-size:200%;
147 | }
148 |
149 | #patterns > li > div:after {
150 | content: "";
151 | position:absolute;
152 | top:-30px;
153 | left:30px;
154 | border:15px solid transparent;
155 | border-bottom-color:currentColor;
156 | border-left-width:0;
157 | }
158 |
159 | #patterns > li:target > div:after {
160 | border-width:30px;
161 | border-left-width:0;
162 | top:-60px;
163 | left:60px;
164 | }
165 |
166 | #patterns > li h2,
167 | #patterns > li p,
168 | #patterns > li textarea {
169 | color:white;
170 | text-shadow: .05em .05em .1em rgba(0,0,0,.4);
171 | }
172 |
173 | #patterns > li h2 {
174 | font-size:140%;
175 | }
176 |
177 | #patterns > li:target h2 {
178 | float: left;
179 | margin-bottom: .3em;
180 | }
181 |
182 | #patterns > li .bytesize {
183 | font-weight:normal;
184 | opacity:.7;
185 | }
186 |
187 | #patterns > li p {
188 | font-size:85%;
189 | line-height:1.8;
190 | opacity:.7;
191 | text-shadow: none;
192 | }
193 |
194 | #patterns > li:target p {
195 | float: right;
196 | }
197 |
198 | #patterns > li textarea {
199 | display:none;
200 | width:100%;
201 | max-height: 50vh;
202 | color:white;
203 | background: #333538;
204 | padding: .5em;
205 | border:0;
206 | font: 100%/1.5 Consolas, Monaco, 'Andale Mono', monospace;
207 | resize:vertical;
208 | box-sizing: border-box;
209 | box-shadow: 1px 1px 10px black inset;
210 | height: calc(var(--lines, 1) * 1.5em + 1em + 16px);
211 | }
212 |
213 | #patterns > li:target textarea {
214 | display:block;
215 | }
216 |
217 | #patterns > li .close {
218 | display:none;
219 | position:absolute;
220 | top:-.5em;
221 | right:-.5em;
222 | width:1.5em;
223 | line-height:1.5;
224 | height:1.5em;
225 | border: .2em solid white;
226 | font-size:80%;
227 | color:white;
228 | background: rgba(20,20,20,.7);
229 | text-align:center;
230 | text-shadow: 1px 1px 3px black;
231 | border-radius:1em;
232 | box-shadow: 1px 1px 5px rgba(0,0,0,.5);
233 | }
234 |
235 | #patterns > li .close:hover {
236 | background:black;
237 | }
238 |
239 | #patterns > li:target .close {
240 | display:block;
241 | }
242 |
243 | #social {
244 | position: fixed;
245 | top: 10px;
246 | left: 10px;
247 | z-index: 2;
248 | }
249 |
250 | #social iframe {
251 | margin-top: .5em;
252 | }
253 |
254 | #footer {
255 | clear:both;
256 | text-align:center;
257 | padding:.5em;
258 | border-top:1px solid rgba(0,0,0,.3);
259 | text-shadow: 0 1px white;
260 | }
261 |
--------------------------------------------------------------------------------