blob: c988a2722027ce366ce52a35cbfc5436d91dcf33 [file] [log] [blame]
AdriĆ 6ae49e72014-11-09 22:21:19 +01001/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in https://chromium.googlesource.com/chromium/src/+/master/LICENSE */
4
5/* This file defines styles for form controls. The order of rule blocks is
6 * important as there are some rules with equal specificity that rely on order
7 * as a tiebreaker. These are marked with OVERRIDE. */
8
9/* Default state **************************************************************/
10
11:-webkit-any(button,
12 input[type='button'],
13 input[type='submit']):not(.custom-appearance):not(.link-button),
14select,
15input[type='checkbox'],
16input[type='radio'] {
17 -webkit-appearance: none;
18 -webkit-user-select: none;
19 background-image: -webkit-linear-gradient(#ededed, #ededed 38%, #dedede);
20 border: 1px solid rgba(0, 0, 0, 0.25);
21 border-radius: 2px;
22 box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08),
23 inset 0 1px 2px rgba(255, 255, 255, 0.75);
24 color: #444;
25 font: inherit;
26 margin: 0 1px 0 0;
27 outline: none;
28 text-shadow: 0 1px 0 rgb(240, 240, 240);
29}
30
31:-webkit-any(button,
32 input[type='button'],
33 input[type='submit']):not(.custom-appearance):not(.link-button),
34select {
35 min-height: 2em;
36 min-width: 4em;
37
38}
39
40:-webkit-any(button,
41 input[type='button'],
42 input[type='submit']):not(.custom-appearance):not(.link-button) {
43 -webkit-padding-end: 10px;
44 -webkit-padding-start: 10px;
45}
46
47select {
48 -webkit-appearance: none;
49 -webkit-padding-end: 20px;
50 -webkit-padding-start: 6px;
51 /* OVERRIDE */
52 background-image: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAICAQAAACxSAwfAAAAUklEQVQY02P4z0AMRGZGMaShwCisyhITmb8huMzfEhOxKvuvsGAh208Ik+3ngoX/FbBbClcIUcSAw21QhXxfIIrwKAMpfNsEUYRXGVCEFc6CQwBqq4CCCtU4VgAAAABJRU5ErkJggg==') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAQCAQAAAA/1a6rAAAAQUlEQVR4Xu3MsQnAMBAEMI1+myf9gw0+3ASCenmu+mQn2yGn3S4Mp906DEW3CEPfzTD03QxD380w3OmIUHe9v+u9QwAt93yns5cAAAAASUVORK5CYII=') 2x),
53 -webkit-linear-gradient(#ededed, #ededed 38%, #dedede);
54 background-position: right center;
55 background-repeat: no-repeat;
56}
57
58html[dir='rtl'] select {
59 background-position: center left;
60}
61
62input[type='checkbox'] {
63
64bottom: 2px;
65 height: 13px;
66 position: relative;
67 vertical-align: middle;
68 width: 13px;
69}
70
71input[type='radio'] {
72 /* OVERRIDE */
73 border-radius: 100%;
74 bottom: 1px;
75 height: 15px;
76 position: relative;
77 vertical-align: middle;
78 width: 15px;
79}
80
81/* TODO(estade): add more types here? */
82input[type='number'],
83input[type='password'],
84input[type='search'],
85input[type='text'],
86input[type='url'],
87input:not([type]),
88textarea {
89 border: 1px solid #bfbfbf;
90 border-radius: 2px;
91 box-sizing: border-box;
92 color: #444;
93 font: inherit;
94 margin: 0;
95 /* Use min-height to accommodate addditional padding for touch as needed. */
96 min-height: 2em;
97 padding: 3px;
98 outline: none;
99/* For better alignment between adjacent buttons and inputs. */
100 padding-bottom: 4px;
101}
102
103input[type='search'] {
104 -webkit-appearance: textfield;
105 /* NOTE: Keep a relatively high min-width for this so we don't obscure the end
106 * of the default text in relatively spacious languages (i.e. German). */
107 min-width: 160px;
108}
109
110/* Remove when https://bugs.webkit.org/show_bug.cgi?id=51499 is fixed.
111 * TODO(dbeam): are there more types that would benefit from this? */
112input[type='search']::-webkit-textfield-decoration-container {
113 direction: inherit;
114}
115
116/* Checked ********************************************************************/
117
118input[type='checkbox']:checked::before {
119 -webkit-user-select: none;
120 background-image: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAQAAAADpb+tAAAAaElEQVR4Xl3PIQoCQQCF4Y8JW42D1bDZ4iVEjDbxFpstYhC7eIVBZHkXFGw734sv/TqDQQ8Xb1udja/I8igeIm7Aygj2IpoKTGZnVRNxAHYi4iPiDlA9xX+aNQDFySziqDN6uSp6y7ofEMwZ05uUZRkAAAAASUVORK5CYII=') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAQAAABuvaSwAAAAvElEQVR4XrXPMUrDYBzG4UeRZnAQnFxq3XT3AsVABm8QPIHQIeAJuoqb2s1BcHAIin4HVLqEvx9NQgb5rc/wvn4mNBUbqlKDcezCp6Qexxx7lbapx/CBe6mrHsYrKXQ7hKtIre1nOD/W9eiQiK80inis680JEc+1kien+TEfzom4sJG2aZXxmG9LIqaRerohx6V2J72zl2NY2OTUgxm7MEU25sURfZg4590Zw5iFZ8mXS0ZwN+eaPjyh/8O/H7bzPJ5NOo0AAAAASUVORK5CYII=') 2x);
121 background-size: 100% 100%;
122 content: '';
123 display: block;
124 height: 100%;
125 width: 100%;
126}
127
128input[type='radio']:checked::before {
129 background-color: #666;
130 border-radius: 100%;
131 bottom: 3px;
132 content: '';
133 display: block;
134 left: 3px;
135 position: absolute;
136 right: 3px;
137 top: 3px;
138}
139
140/* Hover **********************************************************************/
141
142:enabled:hover:-webkit-any(
143 select,
144 input[type='checkbox'],
145 input[type='radio'],
146 :-webkit-any(
147 button,
148 input[type='button'],
149 input[type='submit']):not(.custom-appearance):not(.link-button)) {
150 background-image: -webkit-linear-gradient(#f0f0f0, #f0f0f0 38%, #e0e0e0);
151 border-color: rgba(0, 0, 0, 0.3);
152 box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12),
153 inset 0 1px 2px rgba(255, 255, 255, 0.95);
154 color: black;
155}
156
157:enabled:hover:-webkit-any(select) {
158 /* OVERRIDE */
159 background-image: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAICAQAAACxSAwfAAAAUklEQVQY02P4z0AMRGZGMaShwCisyhITmb8huMzfEhOxKvuvsGAh208Ik+3ngoX/FbBbClcIUcSAw21QhXxfIIrwKAMpfNsEUYRXGVCEFc6CQwBqq4CCCtU4VgAAAABJRU5ErkJggg==') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAQCAQAAAA/1a6rAAAAQUlEQVR4Xu3MsQnAMBAEMI1+myf9gw0+3ASCenmu+mQn2yGn3S4Mp906DEW3CEPfzTD03QxD380w3OmIUHe9v+u9QwAt93yns5cAAAAASUVORK5CYII=') 2x),
160 -webkit-linear-gradient(#f0f0f0, #f0f0f0 38%, #e0e0e0);
161}
162
163/* Active *********************************************************************/
164
165:enabled:active:-webkit-any(
166 select,
167 input[type='checkbox'],
168 input[type='radio'],
169 :-webkit-any(
170 button,
171 input[type='button'],
172 input[type='submit']):not(.custom-appearance):not(.link-button)) {
173 background-image: -webkit-linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7);
174 box-shadow: none;
175 text-shadow: none;
176}
177
178:enabled:active:-webkit-any(select) {
179 /* OVERRIDE */
180 background-image: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAICAQAAACxSAwfAAAAUklEQVQY02P4z0AMRGZGMaShwCisyhITmb8huMzfEhOxKvuvsGAh208Ik+3ngoX/FbBbClcIUcSAw21QhXxfIIrwKAMpfNsEUYRXGVCEFc6CQwBqq4CCCtU4VgAAAABJRU5ErkJggg==') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAQCAQAAAA/1a6rAAAAQUlEQVR4Xu3MsQnAMBAEMI1+myf9gw0+3ASCenmu+mQn2yGn3S4Mp906DEW3CEPfzTD03QxD380w3OmIUHe9v+u9QwAt93yns5cAAAAASUVORK5CYII=') 2x),
181 -webkit-linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7);
182}
183
184/* Disabled *******************************************************************/
185
186:disabled:-webkit-any(
187 button,
188 input[type='button'],
189 input[type='submit']):not(.custom-appearance):not(.link-button),
190select:disabled {
191 background-image: -webkit-linear-gradient(#f1f1f1, #f1f1f1 38%, #e6e6e6);
192 border-color: rgba(80, 80, 80, 0.2);
193 box-shadow: 0 1px 0 rgba(80, 80, 80, 0.08),
194 inset 0 1px 2px rgba(255, 255, 255, 0.75);
195 color: #aaa;
196}
197
198select:disabled {
199 /* OVERRIDE */
200 background-image: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAICAQAAACxSAwfAAAASklEQVQY02P4z0AMRGZGMaShwCisyhITG/4jw8RErMr+KyxYiFC0YOF/BeyWIikEKWLA4Ta4QogiPMpACt82QRThVQYUYYWz4BAAGr6Ii6kEPacAAAAASUVORK5CYII=') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAQCAQAAADQF8WVAAAARElEQVR4Xu3MsQ0AIAwEsYx+m4fySsgLOuTe1Re9z4De4DzbdVDnmZ0ENcrsZJVkdoIKMzurMLOzSjNhlWfCapBlfpZbeMFeGdxKIEQAAAAASUVORK5CYII=') 2x),
201 -webkit-linear-gradient(#f1f1f1, #f1f1f1 38%, #e6e6e6);
202}
203
204input:disabled:-webkit-any([type='checkbox'],
205 [type='radio']) {
206 opacity: .75;
207}
208
209input:disabled:-webkit-any([type='password'],
210 [type='search'],
211 [type='text'],
212 [type='url'],
213 :not([type])) {
214 color: #999;
215}
216
217/* Focus **********************************************************************/
218
219:enabled:focus:-webkit-any(
220 select,
221 input[type='checkbox'],
222 input[type='number'],
223 input[type='password'],
224 input[type='radio'],
225 input[type='search'],
226 input[type='text'],
227 input[type='url'],
228 input:not([type]),
229 :-webkit-any(
230 button,
231 input[type='button'],
232 input[type='submit']):not(.custom-appearance):not(.link-button)) {
233 /* OVERRIDE */
234 -webkit-transition: border-color 200ms;
235 /* We use border color because it follows the border radius (unlike outline).
236 * This is particularly noticeable on mac. */
237 border-color: rgb(77, 144, 254);
238 outline: none;
239}
240
241/* Link buttons ***************************************************************/
242
243.link-button {
244 -webkit-box-shadow: none;
245 background: transparent none;
246 border: none;
247 color: rgb(17, 85, 204);
248 cursor: pointer;
249 /* Input elements have -webkit-small-control which can override the body font.
250 * Resolve this by using 'inherit'. */
251 font: inherit;
252 margin: 0;
253 padding: 0;
254}
255
256.link-button:hover {
257 text-decoration: underline;
258}
259
260.link-button:active {
261 color: rgb(5, 37, 119);
262 text-decoration: underline;
263}
264
265.link-button[disabled] {
266 color: #999;
267 cursor: default;
268 text-decoration: none;
269}
270
271/* Checkbox/radio helpers ******************************************************
272 *
273 * .checkbox and .radio classes wrap labels. Checkboxes and radios should use
274 * these classes with the markup structure:
275 *
276 * <div class="checkbox">
277 * <label>
278 * <input type="checkbox"></input>
279 * <span>
280 * </label>
281 * </div>
282 */
283
284:-webkit-any(.checkbox, .radio) label {
285 /* Don't expand horizontally: <http://crbug.com/112091>. */
286 display: -webkit-inline-box;
287 padding-bottom: 7px;
288 padding-top: 7px;
289}
290
291:-webkit-any(.checkbox, .radio) label input ~ span {
292 -webkit-margin-start: 0.6em;
293 -webkit-user-select: none;
294 /* Make sure long spans wrap at the same horizontal position they start. */
295 display: block;
296}
297
298:-webkit-any(.checkbox, .radio) label:hover {
299 color: black;
300}
301
302label > input:disabled:-webkit-any([type='checkbox'], [type='radio']) ~ span {
303 color: #999;
304}