├── README.md
└── violent-theremin
├── .htaccess
├── README.md
├── app-icons
├── icon-128.png
├── icon-16.png
└── icon-60.png
├── favicon.ico
├── index.html
├── manifest.webapp
├── scripts
├── app.js
└── respond.js
└── styles
├── app.css
└── normalize.css
/README.md:
--------------------------------------------------------------------------------
1 | # violent-theremin
2 |
3 | > **NOTE** This repository has been archived and moved to [webaudio-examples](https://github.com/mdn/webaudio-examples/tree/main/violent-theremin)
4 |
--------------------------------------------------------------------------------
/violent-theremin/.htaccess:
--------------------------------------------------------------------------------
1 | AddType application/x-web-app-manifest+json .webapp
2 |
3 | AddType video/ogg .ogv
4 | AddType video/mp4 .mp4
5 | AddType video/webm .webm
--------------------------------------------------------------------------------
/violent-theremin/README.md:
--------------------------------------------------------------------------------
1 | violent-theremin
2 | ================
3 |
4 | Violent theremin uses the Web Audio API to generate sound, and HTML5 canvas for a bit of pretty visualization. The colours generated depend on the pitch and gain of the current note, which are themselves dependant on the mouse pointer position.
5 |
6 | You can [view the demo](http://mdn.github.io/violent-theremin/) live here.
7 |
--------------------------------------------------------------------------------
/violent-theremin/app-icons/icon-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdn/violent-theremin/cfcf852eae8317bee32f542f7314d7977392efeb/violent-theremin/app-icons/icon-128.png
--------------------------------------------------------------------------------
/violent-theremin/app-icons/icon-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdn/violent-theremin/cfcf852eae8317bee32f542f7314d7977392efeb/violent-theremin/app-icons/icon-16.png
--------------------------------------------------------------------------------
/violent-theremin/app-icons/icon-60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdn/violent-theremin/cfcf852eae8317bee32f542f7314d7977392efeb/violent-theremin/app-icons/icon-60.png
--------------------------------------------------------------------------------
/violent-theremin/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdn/violent-theremin/cfcf852eae8317bee32f542f7314d7977392efeb/violent-theremin/favicon.ico
--------------------------------------------------------------------------------
/violent-theremin/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Click on the browser window or press the tab key to start the app.
21 |
22 |
23 |
Violent Theremin
24 |
25 |
26 |
27 |
Use mouse or arrow keys to control theremin.
28 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/violent-theremin/manifest.webapp:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.1",
3 | "name": "Violent Theremin",
4 | "description": "A sample MDN app that uses Web Audio API to generate an audio tone, the pitch and volume of which is varied by the movement of the mouse and control keys. It also uses HTML5 Canvas to generate some visualizations.",
5 | "launch_path": "/index.html",
6 | "icons": {
7 | "60": "app-icons/icon-60.png",
8 | "128": "app-icons/icon-128.png"
9 | },
10 | "developer": {
11 | "name": "Chris Mills",
12 | "url": "https://developer.mozila.org"
13 | },
14 | "locales": {
15 | "es": {
16 | "description": "A sample MDN app that uses Web Audio API to generate an audio tone, the pitch and volume of which is varied by the movement of the mouse and control keys. It also uses HTML5 Canvas to generate some visualizations.",
17 | "developer": {
18 | "url": "https://developer.mozila.org"
19 | }
20 | },
21 | "it": {
22 | "description": "A sample MDN app that uses Web Audio API to generate an audio tone, the pitch and volume of which is varied by the movement of the mouse and control keys. It also uses HTML5 Canvas to generate some visualizations.",
23 | "developer": {
24 | "url": "https://developer.mozila.org"
25 | }
26 | }
27 | },
28 | "default_locale": "en",
29 | "permissions": {
30 | },
31 | "orientation":"landscape"
32 | }
33 |
--------------------------------------------------------------------------------
/violent-theremin/scripts/app.js:
--------------------------------------------------------------------------------
1 | const appContents = document.querySelector('.app-contents');
2 | const startMessage = document.querySelector('.start-message');
3 | let isAppInit = false;
4 | appContents.style.display = 'none';
5 |
6 | window.addEventListener('keydown', init);
7 | window.addEventListener('click', init);
8 |
9 | function init() {
10 | if (isAppInit) {
11 | return;
12 | }
13 |
14 | appContents.style.display = 'block';
15 | document.body.removeChild(startMessage);
16 |
17 | // create web audio api context
18 | const AudioContext = window.AudioContext || window.webkitAudioContext;
19 | const audioCtx = new AudioContext();
20 |
21 | // create Oscillator and gain node
22 | const oscillator = audioCtx.createOscillator();
23 | const gainNode = audioCtx.createGain();
24 |
25 | // connect oscillator to gain node to speakers
26 | oscillator.connect(gainNode);
27 | gainNode.connect(audioCtx.destination);
28 |
29 | // create initial theremin frequency and volume values
30 | const WIDTH = window.innerWidth;
31 | const HEIGHT = window.innerHeight;
32 |
33 | const maxFreq = 6000;
34 | const maxVol = 0.02;
35 | const initialVol = 0.001;
36 |
37 | // set options for the oscillator
38 | oscillator.detune.value = 100; // value in cents
39 | oscillator.start(0);
40 |
41 | oscillator.onended = function() {
42 | console.log('Your tone has now stopped playing!');
43 | };
44 |
45 | gainNode.gain.value = initialVol;
46 | gainNode.gain.minValue = initialVol;
47 | gainNode.gain.maxValue = initialVol;
48 |
49 | // Mouse pointer coordinates
50 | let CurX;
51 | let CurY;
52 |
53 | // Get new mouse pointer coordinates when mouse is moved
54 | // then set new gain and pitch values
55 | document.onmousemove = updatePage;
56 |
57 | function updatePage(e) {
58 | KeyFlag = false;
59 |
60 | CurX = e.pageX;
61 | CurY = e.pageY;
62 |
63 | oscillator.frequency.value = (CurX/WIDTH) * maxFreq;
64 | gainNode.gain.value = (CurY/HEIGHT) * maxVol;
65 |
66 | canvasDraw();
67 | }
68 |
69 | // mute button
70 | const mute = document.querySelector('.mute');
71 |
72 | mute.onclick = function() {
73 | if (mute.getAttribute('data-muted') === 'false') {
74 | gainNode.disconnect(audioCtx.destination);
75 | mute.setAttribute('data-muted', 'true');
76 | mute.innerHTML = "Unmute";
77 | } else {
78 | gainNode.connect(audioCtx.destination);
79 | mute.setAttribute('data-muted', 'false');
80 | mute.innerHTML = "Mute";
81 | };
82 | }
83 |
84 | // canvas visualization
85 | function random(number1,number2) {
86 | return number1 + (Math.floor(Math.random() * (number2 - number1)) + 1);
87 | }
88 |
89 | const canvas = document.querySelector('.canvas');
90 | const canvasCtx = canvas.getContext('2d');
91 |
92 | canvas.width = WIDTH;
93 | canvas.height = HEIGHT;
94 |
95 | function canvasDraw() {
96 | if (KeyFlag) {
97 | rX = KeyX;
98 | rY = KeyY;
99 | } else {
100 | rX = CurX;
101 | rY = CurY;
102 | }
103 |
104 | rC = Math.floor((gainNode.gain.value/maxVol)*30);
105 |
106 | canvasCtx.globalAlpha = 0.2;
107 |
108 | for (let i = 1; i <= 15; i = i+2) {
109 | canvasCtx.beginPath();
110 | canvasCtx.fillStyle = 'rgb(' + 100+(i*10) + ',' + Math.floor((gainNode.gain.value/maxVol)*255) + ',' + Math.floor((oscillator.frequency.value/maxFreq)*255) + ')';
111 | canvasCtx.arc(rX+random(0,50),rY+random(0,50),rC/2+i,(Math.PI/180)*0,(Math.PI/180)*360,false);
112 | canvasCtx.fill();
113 | canvasCtx.closePath();
114 | }
115 | }
116 |
117 | // clear screen
118 | const clear = document.querySelector('.clear');
119 |
120 | clear.onclick = function() {
121 | canvasCtx.clearRect(0, 0, canvas.width, canvas.height);
122 | }
123 |
124 | // keyboard controls
125 | const body = document.querySelector('body');
126 |
127 | let KeyX = 1;
128 | let KeyY = 0.01;
129 | let KeyFlag = false;
130 |
131 | const ARROW_LEFT = 'ArrowLeft';
132 | const ARROW_RIGHT = 'ArrowRight';
133 | const ARROW_UP = 'ArrowUp';
134 | const ARROW_DOWN = 'ArrowDown';
135 |
136 | body.onkeydown = function(e) {
137 | KeyFlag = true;
138 |
139 | if (e.code === ARROW_LEFT) {
140 | KeyX -= 20;
141 | }
142 |
143 | if (e.code === ARROW_RIGHT) {
144 | KeyX += 20;
145 | }
146 |
147 | if (e.code === ARROW_UP) {
148 | KeyY -= 20;
149 | }
150 |
151 | if (e.code === ARROW_DOWN) {
152 | KeyY += 20;
153 | }
154 |
155 | // set max and min constraints for KeyX and KeyY
156 | if (KeyX < 1) {
157 | KeyX = 1;
158 | }
159 |
160 | if (KeyX > WIDTH) {
161 | KeyX = WIDTH;
162 | }
163 |
164 | if (KeyY < 0.01) {
165 | KeyY = 0.01;
166 | }
167 |
168 | if (KeyY > HEIGHT) {
169 | KeyY = HEIGHT;
170 | }
171 |
172 | oscillator.frequency.value = (KeyX/WIDTH) * maxFreq;
173 | gainNode.gain.value = (KeyY/HEIGHT) * maxVol;
174 |
175 | canvasDraw();
176 | };
177 |
178 | isAppInit = true;
179 | }
180 |
--------------------------------------------------------------------------------
/violent-theremin/scripts/respond.js:
--------------------------------------------------------------------------------
1 | /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
2 | /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */
3 | window.matchMedia=window.matchMedia||function(a){"use strict";var c,d=a.documentElement,e=d.firstElementChild||d.firstChild,f=a.createElement("body"),g=a.createElement("div");return g.id="mq-test-1",g.style.cssText="position:absolute;top:-100em",f.style.background="none",f.appendChild(g),function(a){return g.innerHTML='',d.insertBefore(f,e),c=42===g.offsetWidth,d.removeChild(f),{matches:c,media:a}}}(document);
4 |
5 | /*! Respond.js v1.3.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */
6 | (function(a){"use strict";function x(){u(!0)}var b={};if(a.respond=b,b.update=function(){},b.mediaQueriesSupported=a.matchMedia&&a.matchMedia("only all").matches,!b.mediaQueriesSupported){var q,r,t,c=a.document,d=c.documentElement,e=[],f=[],g=[],h={},i=30,j=c.getElementsByTagName("head")[0]||d,k=c.getElementsByTagName("base")[0],l=j.getElementsByTagName("link"),m=[],n=function(){for(var b=0;l.length>b;b++){var c=l[b],d=c.href,e=c.media,f=c.rel&&"stylesheet"===c.rel.toLowerCase();d&&f&&!h[d]&&(c.styleSheet&&c.styleSheet.rawCssText?(p(c.styleSheet.rawCssText,d,e),h[d]=!0):(!/^([a-zA-Z:]*\/\/)/.test(d)&&!k||d.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&m.push({href:d,media:e}))}o()},o=function(){if(m.length){var b=m.shift();v(b.href,function(c){p(c,b.href,b.media),h[b.href]=!0,a.setTimeout(function(){o()},0)})}},p=function(a,b,c){var d=a.match(/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi),g=d&&d.length||0;b=b.substring(0,b.lastIndexOf("/"));var h=function(a){return a.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+b+"$2$3")},i=!g&&c;b.length&&(b+="/"),i&&(g=1);for(var j=0;g>j;j++){var k,l,m,n;i?(k=c,f.push(h(a))):(k=d[j].match(/@media *([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1,f.push(RegExp.$2&&h(RegExp.$2))),m=k.split(","),n=m.length;for(var o=0;n>o;o++)l=m[o],e.push({media:l.split("(")[0].match(/(only\s+)?([a-zA-Z]+)\s?/)&&RegExp.$2||"all",rules:f.length-1,hasquery:l.indexOf("(")>-1,minw:l.match(/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},s=function(){var a,b=c.createElement("div"),e=c.body,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",e||(e=f=c.createElement("body"),e.style.background="none"),e.appendChild(b),d.insertBefore(e,d.firstChild),a=b.offsetWidth,f?d.removeChild(e):e.removeChild(b),a=t=parseFloat(a)},u=function(b){var h="clientWidth",k=d[h],m="CSS1Compat"===c.compatMode&&k||c.body[h]||k,n={},o=l[l.length-1],p=(new Date).getTime();if(b&&q&&i>p-q)return a.clearTimeout(r),r=a.setTimeout(u,i),void 0;q=p;for(var v in e)if(e.hasOwnProperty(v)){var w=e[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?t||s():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?t||s():1)),w.hasquery&&(z&&A||!(z||m>=x)||!(A||y>=m))||(n[w.media]||(n[w.media]=[]),n[w.media].push(f[w.rules]))}for(var C in g)g.hasOwnProperty(C)&&g[C]&&g[C].parentNode===j&&j.removeChild(g[C]);for(var D in n)if(n.hasOwnProperty(D)){var E=c.createElement("style"),F=n[D].join("\n");E.type="text/css",E.media=D,j.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(c.createTextNode(F)),g.push(E)}},v=function(a,b){var c=w();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))},w=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}();n(),b.update=n,a.addEventListener?a.addEventListener("resize",x,!1):a.attachEvent&&a.attachEvent("onresize",x)}})(this);
7 |
--------------------------------------------------------------------------------
/violent-theremin/styles/app.css:
--------------------------------------------------------------------------------
1 | /* general styling */
2 |
3 | html {
4 | font-size: 10px;
5 | height: 100%;
6 | }
7 |
8 | body {
9 | width: 100%;
10 | height: inherit;
11 | }
12 |
13 | canvas {
14 | display: block;
15 | }
16 |
17 | /* header styling */
18 |
19 | h1 {
20 | position: absolute;
21 | bottom: 10px;
22 | right: 15px;
23 | font-size: 3rem;
24 | margin: 0;
25 | color: white;
26 | text-shadow: 0 0 10px rgba(0,0,0,0.3) ;
27 | }
28 |
29 | /* button styling */
30 |
31 | button {
32 | background-color: #0088cc;
33 | background-image: linear-gradient(to bottom, #0088cc 0%,#0055cc 100%);
34 | text-shadow: 1px 1px 1px black;
35 | text-align: center;
36 | color: white;
37 | border: none;
38 | width: 150px;
39 | font-size: 1.6rem;
40 | line-height: 2rem;
41 | padding: .5rem;
42 | display: block;
43 | opacity: 0.3;
44 |
45 | transition: 1s all;
46 | -webkit-transition: 1s all;
47 |
48 | position: absolute;
49 | }
50 |
51 | button:hover, button:focus {
52 | box-shadow: inset 1px 1px 2px rgba(0,0,0,0.7);
53 | opacity: 1;
54 | }
55 |
56 | button:active {
57 | box-shadow: inset 2px 2px 3px rgba(0,0,0,0.7);
58 | }
59 |
60 | #activated {
61 | background-color: red;
62 | color: white;
63 | }
64 |
65 | .mute {
66 | top: 41px;
67 | left: 5px;
68 | }
69 |
70 | .clear {
71 | top: 6px;
72 | left: 5px;
73 | }
74 |
75 | .start-message {
76 | position: absolute;
77 | font-size: 1.4rem;
78 | left: 5px;
79 | }
80 |
81 | .control-message {
82 | position: absolute;
83 | font-size: 1.4rem;
84 | top: 70px;
85 | left: 5px;
86 | }
87 |
--------------------------------------------------------------------------------
/violent-theremin/styles/normalize.css:
--------------------------------------------------------------------------------
1 | /*! normalize.css v2.1.3 | MIT License | git.io/normalize */
2 |
3 | /* ==========================================================================
4 | HTML5 display definitions
5 | ========================================================================== */
6 |
7 | /**
8 | * Correct `block` display not defined in IE 8/9.
9 | */
10 |
11 | article,
12 | aside,
13 | details,
14 | figcaption,
15 | figure,
16 | footer,
17 | header,
18 | hgroup,
19 | main,
20 | nav,
21 | section,
22 | summary {
23 | display: block;
24 | }
25 |
26 | /**
27 | * Correct `inline-block` display not defined in IE 8/9.
28 | */
29 |
30 | audio,
31 | canvas,
32 | video {
33 | display: inline-block;
34 | }
35 |
36 | /**
37 | * Prevent modern browsers from displaying `audio` without controls.
38 | * Remove excess height in iOS 5 devices.
39 | */
40 |
41 | audio:not([controls]) {
42 | display: none;
43 | height: 0;
44 | }
45 |
46 | /**
47 | * Address `[hidden]` styling not present in IE 8/9.
48 | * Hide the `template` element in IE, Safari, and Firefox < 22.
49 | */
50 |
51 | [hidden],
52 | template {
53 | display: none;
54 | }
55 |
56 | /* ==========================================================================
57 | Base
58 | ========================================================================== */
59 |
60 | /**
61 | * 1. Set default font family to sans-serif.
62 | * 2. Prevent iOS text size adjust after orientation change, without disabling
63 | * user zoom.
64 | */
65 |
66 | html {
67 | font-family: sans-serif; /* 1 */
68 | -ms-text-size-adjust: 100%; /* 2 */
69 | -webkit-text-size-adjust: 100%; /* 2 */
70 | }
71 |
72 | /**
73 | * Remove default margin.
74 | */
75 |
76 | body {
77 | margin: 0;
78 | }
79 |
80 | /* ==========================================================================
81 | Links
82 | ========================================================================== */
83 |
84 | /**
85 | * Remove the gray background color from active links in IE 10.
86 | */
87 |
88 | a {
89 | background: transparent;
90 | }
91 |
92 | /**
93 | * Address `outline` inconsistency between Chrome and other browsers.
94 | */
95 |
96 | a:focus {
97 | outline: thin dotted;
98 | }
99 |
100 | /**
101 | * Improve readability when focused and also mouse hovered in all browsers.
102 | */
103 |
104 | a:active,
105 | a:hover {
106 | outline: 0;
107 | }
108 |
109 | /* ==========================================================================
110 | Typography
111 | ========================================================================== */
112 |
113 | /**
114 | * Address variable `h1` font-size and margin within `section` and `article`
115 | * contexts in Firefox 4+, Safari 5, and Chrome.
116 | */
117 |
118 | h1 {
119 | font-size: 2em;
120 | margin: 0.67em 0;
121 | }
122 |
123 | /**
124 | * Address styling not present in IE 8/9, Safari 5, and Chrome.
125 | */
126 |
127 | abbr[title] {
128 | border-bottom: 1px dotted;
129 | }
130 |
131 | /**
132 | * Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome.
133 | */
134 |
135 | b,
136 | strong {
137 | font-weight: bold;
138 | }
139 |
140 | /**
141 | * Address styling not present in Safari 5 and Chrome.
142 | */
143 |
144 | dfn {
145 | font-style: italic;
146 | }
147 |
148 | /**
149 | * Address differences between Firefox and other browsers.
150 | */
151 |
152 | hr {
153 | -moz-box-sizing: content-box;
154 | box-sizing: content-box;
155 | height: 0;
156 | }
157 |
158 | /**
159 | * Address styling not present in IE 8/9.
160 | */
161 |
162 | mark {
163 | background: #ff0;
164 | color: #000;
165 | }
166 |
167 | /**
168 | * Correct font family set oddly in Safari 5 and Chrome.
169 | */
170 |
171 | code,
172 | kbd,
173 | pre,
174 | samp {
175 | font-family: monospace, serif;
176 | font-size: 1em;
177 | }
178 |
179 | /**
180 | * Improve readability of pre-formatted text in all browsers.
181 | */
182 |
183 | pre {
184 | white-space: pre-wrap;
185 | }
186 |
187 | /**
188 | * Set consistent quote types.
189 | */
190 |
191 | q {
192 | quotes: "\201C" "\201D" "\2018" "\2019";
193 | }
194 |
195 | /**
196 | * Address inconsistent and variable font size in all browsers.
197 | */
198 |
199 | small {
200 | font-size: 80%;
201 | }
202 |
203 | /**
204 | * Prevent `sub` and `sup` affecting `line-height` in all browsers.
205 | */
206 |
207 | sub,
208 | sup {
209 | font-size: 75%;
210 | line-height: 0;
211 | position: relative;
212 | vertical-align: baseline;
213 | }
214 |
215 | sup {
216 | top: -0.5em;
217 | }
218 |
219 | sub {
220 | bottom: -0.25em;
221 | }
222 |
223 | /* ==========================================================================
224 | Embedded content
225 | ========================================================================== */
226 |
227 | /**
228 | * Remove border when inside `a` element in IE 8/9.
229 | */
230 |
231 | img {
232 | border: 0;
233 | }
234 |
235 | /**
236 | * Correct overflow displayed oddly in IE 9.
237 | */
238 |
239 | svg:not(:root) {
240 | overflow: hidden;
241 | }
242 |
243 | /* ==========================================================================
244 | Figures
245 | ========================================================================== */
246 |
247 | /**
248 | * Address margin not present in IE 8/9 and Safari 5.
249 | */
250 |
251 | figure {
252 | margin: 0;
253 | }
254 |
255 | /* ==========================================================================
256 | Forms
257 | ========================================================================== */
258 |
259 | /**
260 | * Define consistent border, margin, and padding.
261 | */
262 |
263 | fieldset {
264 | border: 1px solid #c0c0c0;
265 | margin: 0 2px;
266 | padding: 0.35em 0.625em 0.75em;
267 | }
268 |
269 | /**
270 | * 1. Correct `color` not being inherited in IE 8/9.
271 | * 2. Remove padding so people aren't caught out if they zero out fieldsets.
272 | */
273 |
274 | legend {
275 | border: 0; /* 1 */
276 | padding: 0; /* 2 */
277 | }
278 |
279 | /**
280 | * 1. Correct font family not being inherited in all browsers.
281 | * 2. Correct font size not being inherited in all browsers.
282 | * 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome.
283 | */
284 |
285 | button,
286 | input,
287 | select,
288 | textarea {
289 | font-family: inherit; /* 1 */
290 | font-size: 100%; /* 2 */
291 | margin: 0; /* 3 */
292 | }
293 |
294 | /**
295 | * Address Firefox 4+ setting `line-height` on `input` using `!important` in
296 | * the UA stylesheet.
297 | */
298 |
299 | button,
300 | input {
301 | line-height: normal;
302 | }
303 |
304 | /**
305 | * Address inconsistent `text-transform` inheritance for `button` and `select`.
306 | * All other form control elements do not inherit `text-transform` values.
307 | * Correct `button` style inheritance in Chrome, Safari 5+, and IE 8+.
308 | * Correct `select` style inheritance in Firefox 4+ and Opera.
309 | */
310 |
311 | button,
312 | select {
313 | text-transform: none;
314 | }
315 |
316 | /**
317 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
318 | * and `video` controls.
319 | * 2. Correct inability to style clickable `input` types in iOS.
320 | * 3. Improve usability and consistency of cursor style between image-type
321 | * `input` and others.
322 | */
323 |
324 | button,
325 | html input[type="button"], /* 1 */
326 | input[type="reset"],
327 | input[type="submit"] {
328 | -webkit-appearance: button; /* 2 */
329 | cursor: pointer; /* 3 */
330 | }
331 |
332 | /**
333 | * Re-set default cursor for disabled elements.
334 | */
335 |
336 | button[disabled],
337 | html input[disabled] {
338 | cursor: default;
339 | }
340 |
341 | /**
342 | * 1. Address box sizing set to `content-box` in IE 8/9/10.
343 | * 2. Remove excess padding in IE 8/9/10.
344 | */
345 |
346 | input[type="checkbox"],
347 | input[type="radio"] {
348 | box-sizing: border-box; /* 1 */
349 | padding: 0; /* 2 */
350 | }
351 |
352 | /**
353 | * 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome.
354 | * 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome
355 | * (include `-moz` to future-proof).
356 | */
357 |
358 | input[type="search"] {
359 | -webkit-appearance: textfield; /* 1 */
360 | -moz-box-sizing: content-box;
361 | -webkit-box-sizing: content-box; /* 2 */
362 | box-sizing: content-box;
363 | }
364 |
365 | /**
366 | * Remove inner padding and search cancel button in Safari 5 and Chrome
367 | * on OS X.
368 | */
369 |
370 | input[type="search"]::-webkit-search-cancel-button,
371 | input[type="search"]::-webkit-search-decoration {
372 | -webkit-appearance: none;
373 | }
374 |
375 | /**
376 | * Remove inner padding and border in Firefox 4+.
377 | */
378 |
379 | button::-moz-focus-inner,
380 | input::-moz-focus-inner {
381 | border: 0;
382 | padding: 0;
383 | }
384 |
385 | /**
386 | * 1. Remove default vertical scrollbar in IE 8/9.
387 | * 2. Improve readability and alignment in all browsers.
388 | */
389 |
390 | textarea {
391 | overflow: auto; /* 1 */
392 | vertical-align: top; /* 2 */
393 | }
394 |
395 | /* ==========================================================================
396 | Tables
397 | ========================================================================== */
398 |
399 | /**
400 | * Remove most spacing between table cells.
401 | */
402 |
403 | table {
404 | border-collapse: collapse;
405 | border-spacing: 0;
406 | }
407 |
--------------------------------------------------------------------------------