Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 /* This file defines styles for form controls. The order of rule blocks is | |
| 7 * important as there are some rules with equal specificity that rely on order | |
| 8 * as a tiebreaker. These are marked with OVERRIDE. | |
|
Dan Beam
2012/03/06 04:47:07
and the community thinks we write CSS like C++, ha
| |
| 9 */ | |
| 10 | |
| 6 /* Default state **************************************************************/ | 11 /* Default state **************************************************************/ |
| 7 | 12 |
| 8 button:not(.custom-appearance):not(.link-button), | 13 button:not(.custom-appearance):not(.link-button), |
| 9 input[type='button']:not(.custom-appearance):not(.link-button), | 14 input[type='button']:not(.custom-appearance):not(.link-button), |
| 10 input[type='submit']:not(.custom-appearance):not(.link-button), | 15 input[type='submit']:not(.custom-appearance):not(.link-button), |
| 11 select { | 16 select, |
| 17 input[type='checkbox'], | |
| 18 input[type='radio'] { | |
|
Dan Beam
2012/03/06 04:47:07
why not group inputs?
Evan Stade
2012/03/06 05:18:15
why group inputs? input[type='button'] has a lot m
Dan Beam
2012/03/06 05:50:10
ok, I see your point
| |
| 19 -webkit-appearance: none; | |
| 12 -webkit-user-select: none; | 20 -webkit-user-select: none; |
| 21 background-image: -webkit-linear-gradient(#ededed, #ededed 38%, #dedede); | |
| 13 border-radius: 2px; | 22 border-radius: 2px; |
| 14 border: 1px solid rgba(0, 0, 0, 0.25); | 23 border: 1px solid rgba(0, 0, 0, 0.25); |
| 15 box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), | 24 box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), |
| 16 inset 0 1px 2px rgba(255, 255, 255, 0.75); | 25 inset 0 1px 2px rgba(255, 255, 255, 0.75); |
| 17 color: #444; | 26 color: #444; |
| 18 font: inherit; | 27 font: inherit; |
| 28 margin: 0 1px 0 0; | |
| 29 text-shadow: 0 1px 0 rgb(240, 240, 240); | |
| 30 } | |
| 31 | |
| 32 button:not(.custom-appearance):not(.link-button), | |
| 33 input[type='button']:not(.custom-appearance):not(.link-button), | |
| 34 input[type='submit']:not(.custom-appearance):not(.link-button), | |
| 35 select { | |
| 19 height: 2em; | 36 height: 2em; |
| 20 margin: 0 1px 0 0; | |
| 21 min-width: 4em; | 37 min-width: 4em; |
| 22 text-shadow: 0 1px 0 rgb(240, 240, 240); | |
| 23 } | 38 } |
| 24 | 39 |
| 25 button:not(.custom-appearance):not(.link-button), | 40 button:not(.custom-appearance):not(.link-button), |
| 26 input[type='button']:not(.custom-appearance):not(.link-button), | 41 input[type='button']:not(.custom-appearance):not(.link-button), |
| 27 input[type='submit']:not(.custom-appearance):not(.link-button) { | 42 input[type='submit']:not(.custom-appearance):not(.link-button) { |
| 28 -webkit-padding-end: 10px; | 43 -webkit-padding-end: 10px; |
| 29 -webkit-padding-start: 10px; | 44 -webkit-padding-start: 10px; |
| 30 background-image: | |
| 31 -webkit-gradient(linear, left top, left bottom, | |
| 32 color-stop(0, rgb(237, 237, 237)), | |
| 33 color-stop(0.38, rgb(237, 237, 237)), | |
| 34 color-stop(1, rgb(222, 222, 222))); | |
| 35 } | 45 } |
| 36 | 46 |
| 37 select { | 47 select { |
| 38 -webkit-appearance: none; | 48 -webkit-appearance: none; |
| 39 -webkit-padding-end: 20px; | 49 -webkit-padding-end: 20px; |
| 40 -webkit-padding-start: 6px; | 50 -webkit-padding-start: 6px; |
| 51 /* OVERRIDE */ | |
| 41 background-image: url('../images/select.png'), | 52 background-image: url('../images/select.png'), |
| 42 -webkit-gradient(linear, left top, left bottom, | 53 -webkit-linear-gradient(#ededed, #ededed 38%, #dedede); |
| 43 color-stop(0, rgb(237, 237, 237)), | |
| 44 color-stop(0.38, rgb(237, 237, 237)), | |
| 45 color-stop(1, rgb(222, 222, 222))); | |
| 46 background-position: right center; | 54 background-position: right center; |
| 47 background-repeat: no-repeat; | 55 background-repeat: no-repeat; |
| 48 overflow: hidden; | 56 overflow: hidden; |
| 49 text-align: left; | 57 text-align: left; |
| 50 text-overflow: ellipsis; | 58 text-overflow: ellipsis; |
| 51 white-space: nowrap; | 59 white-space: nowrap; |
| 52 } | 60 } |
| 53 | 61 |
| 54 html[dir='rtl'] select { | 62 html[dir='rtl'] select { |
| 55 background-position: center left; | 63 background-position: center left; |
| 56 } | 64 } |
| 57 | 65 |
| 66 input[type='checkbox'] { | |
| 67 border-radius: 2px; | |
| 68 height: 13px; | |
| 69 position: relative; | |
| 70 top: 2px; | |
| 71 width: 13px; | |
| 72 } | |
| 73 | |
| 74 input[type='radio'] { | |
| 75 border-radius: 100%; | |
| 76 height: 15px; | |
| 77 position: relative; | |
| 78 width: 15px; | |
| 79 } | |
| 80 | |
| 81 /* Checked ********************************************************************/ | |
| 82 | |
| 83 input[type='checkbox']:checked::before { | |
| 84 -webkit-user-select: none; | |
| 85 content: url('../images/check.png'); | |
| 86 } | |
| 87 | |
| 88 input[type='radio']:checked::before { | |
| 89 background-color: #666; | |
| 90 border-radius: 100%; | |
| 91 content: ''; | |
| 92 display: inline-block; | |
| 93 height: 7px; | |
| 94 left: 3px; | |
| 95 position: absolute; | |
| 96 top: 3px; | |
| 97 width: 7px; | |
| 98 } | |
| 99 | |
| 100 html[dir='rtl'] input[type='radio']:checked::before { | |
| 101 right: 0; | |
| 102 } | |
| 103 | |
| 58 /* Hover **********************************************************************/ | 104 /* Hover **********************************************************************/ |
| 59 | 105 |
| 60 button:not(.custom-appearance):not(.link-button):enabled:hover, | 106 button:not(.custom-appearance):not(.link-button):enabled:hover, |
| 61 input[type='button']:not(.custom-appearance):not(.link-button):enabled:hover, | 107 input[type='button']:not(.custom-appearance):not(.link-button):enabled:hover, |
| 62 input[type='submit']:not(.custom-appearance):not(.link-button):enabled:hover { | |
| 63 background-image: -webkit-gradient(linear, left top, left bottom, | |
| 64 color-stop(0, rgb(240, 240, 240)), | |
| 65 color-stop(0.38, rgb(240, 240, 240)), | |
| 66 color-stop(1, rgb(224, 224, 224))); | |
| 67 } | |
| 68 | |
| 69 select:enabled:hover { | |
| 70 background-image: url('../images/select.png'), | |
| 71 -webkit-gradient(linear, left top, left bottom, | |
| 72 color-stop(0, rgb(237, 237, 237)), | |
| 73 color-stop(0.38, rgb(237, 237, 237)), | |
| 74 color-stop(1, rgb(222, 222, 222))); | |
| 75 } | |
| 76 | |
| 77 button:not(.custom-appearance):not(.link-button):enabled:hover, | |
| 78 input[type='button']:not(.custom-appearance):not(.link-button):enabled:hover, | |
| 79 input[type='submit']:not(.custom-appearance):not(.link-button):enabled:hover, | 108 input[type='submit']:not(.custom-appearance):not(.link-button):enabled:hover, |
| 80 select:enabled:hover { | 109 select:enabled:hover, |
| 110 input[type='checkbox']:enabled:hover, | |
| 111 input[type='radio']:enabled:hover { | |
| 112 background-image: -webkit-linear-gradient(#f0f0f0, #f0f0f0 38%, #e0e0e0); | |
| 81 border-color: rgba(0, 0, 0, 0.3); | 113 border-color: rgba(0, 0, 0, 0.3); |
| 82 box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12), | 114 box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12), |
| 83 inset 0 1px 2px rgba(255, 255, 255, 0.95); | 115 inset 0 1px 2px rgba(255, 255, 255, 0.95); |
| 84 color: black; | 116 color: black; |
| 85 } | 117 } |
| 86 | 118 |
| 119 select:enabled:hover { | |
| 120 /* OVERRIDE */ | |
| 121 background-image: url('../images/select.png'), | |
| 122 -webkit-linear-gradient(#f0f0f0, #f0f0f0 38%, #e0e0e0); | |
| 123 } | |
| 124 | |
| 87 /* Active *********************************************************************/ | 125 /* Active *********************************************************************/ |
| 88 | 126 |
| 89 button:not(.custom-appearance):not(.link-button):enabled:active, | 127 button:not(.custom-appearance):not(.link-button):enabled:active, |
| 90 input[type='button']:not(.custom-appearance):not(.link-button):enabled:active, | 128 input[type='button']:not(.custom-appearance):not(.link-button):enabled:active, |
| 91 input[type='submit']:not(.custom-appearance):not(.link-button):enabled:active { | 129 input[type='submit']:not(.custom-appearance):not(.link-button):enabled:active, |
| 92 background-image: -webkit-gradient(linear, left top, left bottom, | 130 select:enabled:active, |
| 93 color-stop(0, rgb(231, 231, 231)), | 131 input[type='checkbox']:enabled:active, |
| 94 color-stop(0.38, rgb(231, 231, 231)), | 132 input[type='radio']:enabled:active { |
| 95 color-stop(1, rgb(215, 215, 215))); | 133 background-image: -webkit-linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7); |
| 134 box-shadow: none; | |
| 135 text-shadow: none; | |
| 96 } | 136 } |
| 97 | 137 |
| 98 select:enabled:active { | 138 select:enabled:active { |
| 139 /* OVERRIDE */ | |
| 99 background-image: url('../images/select.png'), | 140 background-image: url('../images/select.png'), |
| 100 -webkit-gradient(linear, left top, left bottom, | 141 -webkit-linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7); |
| 101 color-stop(0, rgb(231, 231, 231)), | |
| 102 color-stop(0.38, rgb(231, 231, 231)), | |
| 103 color-stop(1, rgb(215, 215, 215))); | |
| 104 } | |
| 105 | |
| 106 button:not(.custom-appearance):not(.link-button):enabled:active, | |
| 107 input[type='button']:not(.custom-appearance):not(.link-button):enabled:active, | |
| 108 input[type='submit']:not(.custom-appearance):not(.link-button):enabled:active, | |
| 109 select:enabled:active { | |
| 110 box-shadow: none; | |
| 111 text-shadow: none; | |
| 112 } | 142 } |
| 113 | 143 |
| 114 /* Disabled *******************************************************************/ | 144 /* Disabled *******************************************************************/ |
| 115 | 145 |
| 116 button:not(.custom-appearance):not(.link-button):disabled, | 146 button:not(.custom-appearance):not(.link-button):disabled, |
| 117 input[type='button']:not(.custom-appearance):not(.link-button):disabled, | 147 input[type='button']:not(.custom-appearance):not(.link-button):disabled, |
| 118 input[type='submit']:not(.custom-appearance):not(.link-button):disabled, | 148 input[type='submit']:not(.custom-appearance):not(.link-button):disabled, |
| 119 select:disabled { | 149 select:disabled { |
| 120 border-color: rgba(0, 0, 0, 0.2); | 150 border-color: rgba(0, 0, 0, 0.2); |
| 121 color: #999; | 151 color: #999; |
| 122 } | 152 } |
| 123 | 153 |
| 124 select:disabled { | 154 select:disabled { |
| 125 background-image: url('../images/disabled_select.png'), | 155 background-image: url('../images/disabled_select.png'), |
| 126 -webkit-gradient(linear, left top, left bottom, | 156 -webkit-linear-gradient(#ededed, #ededed 38%, #dedede); |
| 127 color-stop(0, rgb(237, 237, 237)), | 157 } |
| 128 color-stop(0.38, rgb(237, 237, 237)), | 158 |
| 129 color-stop(1, rgb(222, 222, 222))); | 159 input[type='checkbox']:disabled, |
| 160 input[type='radio']:disabled { | |
| 161 opacity: .75; | |
| 130 } | 162 } |
| 131 | 163 |
| 132 /* Focus **********************************************************************/ | 164 /* Focus **********************************************************************/ |
| 133 | 165 |
| 134 button:not(.custom-appearance):not(.link-button):focus, | 166 button:not(.custom-appearance):not(.link-button):focus, |
| 135 input[type='submit']:not(.custom-appearance):focus, | 167 input[type='submit']:not(.custom-appearance):focus, |
| 136 input[type='text']:not(.custom-appearance):focus, | 168 input[type='text']:focus, |
| 169 input[type='checkbox']:focus, | |
| 170 input[type='radio']:focus, | |
| 137 select:focus { | 171 select:focus { |
| 138 -webkit-transition: border-color 200ms; | 172 -webkit-transition: border-color 200ms; |
| 139 /* We use border color because it follows the border radius (unlike outline). | 173 /* We use border color because it follows the border radius (unlike outline). |
| 140 * This is particularly noticeable on mac. */ | 174 * This is particularly noticeable on mac. */ |
| 141 border-color: rgb(77, 144, 254); | 175 border-color: rgb(77, 144, 254); |
| 142 outline: none; | 176 outline: none; |
| 143 } | 177 } |
| 144 | 178 |
| 145 /* Search boxes use an outline because it follows the contours of the box. */ | 179 /* Search boxes use an outline because it follows the contours of the box. */ |
| 146 input[type='search']:not(.custom-appearance):focus { | 180 input[type='search']:not(.custom-appearance):focus { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 169 .link-button:active { | 203 .link-button:active { |
| 170 color: rgb(5, 37, 119); | 204 color: rgb(5, 37, 119); |
| 171 text-decoration: underline; | 205 text-decoration: underline; |
| 172 } | 206 } |
| 173 | 207 |
| 174 .link-button[disabled] { | 208 .link-button[disabled] { |
| 175 color: #888; | 209 color: #888; |
| 176 cursor: default; | 210 cursor: default; |
| 177 text-decoration: none; | 211 text-decoration: none; |
| 178 } | 212 } |
| 213 | |
| 214 /* Checkbox/radio helpers ****************************************************** | |
| 215 * | |
| 216 * .checkbox and .radio classes wrap labels. Checkboxes and radios should use | |
| 217 * these classes in the form: | |
|
Dan Beam
2012/03/06 04:47:07
s/form/markup structure/?
Evan Stade
2012/03/06 05:18:15
why?
Dan Beam
2012/03/06 05:50:10
seems less ambiguous - in the form could mean anyt
Evan Stade
2012/03/06 22:54:51
Done.
| |
| 218 * | |
| 219 * <div class="checkbox"> | |
| 220 * <label> | |
| 221 * <input type="checkbox"></input> | |
| 222 * <span> | |
|
Dan Beam
2012/03/06 04:47:07
do you want to end this span?
Evan Stade
2012/03/06 05:18:15
ok
| |
| 223 * </label> | |
| 224 * </div> | |
| 225 */ | |
| 226 | |
| 227 .checkbox, | |
| 228 .radio { | |
| 229 margin: 0.45em 0; | |
| 230 } | |
| 231 | |
| 232 .checkbox label, | |
| 233 .radio label { | |
| 234 color: #444; | |
| 235 /* Don't expand horizontally: http://crbug.com/112091 */ | |
|
Dan Beam
2012/03/06 04:47:07
. at end
Evan Stade
2012/03/06 22:54:51
Done.
| |
| 236 display: -webkit-inline-box; | |
| 237 } | |
| 238 | |
| 239 .checkbox label input ~ span, | |
| 240 .radio label input ~ span { | |
| 241 -webkit-margin-start: 0.4em; | |
| 242 /* Make sure long spans wrap at the same horizontal position they start. */ | |
| 243 display: block; | |
| 244 } | |
| 245 | |
| 246 .checkbox label:hover, | |
| 247 .radio label:hover { | |
| 248 color: black; | |
| 249 } | |
| 250 | |
| 251 label > input[type=checkbox]:disabled ~ span, | |
| 252 label > input[type=radio]:disabled ~ span { | |
| 253 color: #999; | |
| 254 } | |
| 255 | |
| 256 /* Text inputs ****************************************************************/ | |
| 257 /* TODO(estade): add more types here? */ | |
|
Dan Beam
2012/03/06 04:47:07
moar types?!
| |
| 258 input[type='password'], | |
| 259 input[type='search'], | |
| 260 input[type='text'], | |
| 261 input[type='url'], | |
| 262 input:not([type]) { | |
| 263 border: 1px solid #bfbfbf; | |
| 264 border-radius: 2px; | |
|
Patrick Dubroy
2012/03/06 22:58:28
Maybe these rules be should shared with type='subm
Evan Stade
2012/03/06 23:21:56
most of them are not shareable, and the ones that
| |
| 265 font: inherit; | |
| 266 height: 2em; | |
| 267 margin: 0; | |
| 268 padding: 3px; | |
| 269 } | |
| 270 | |
| 271 input[type='search'] { | |
| 272 /* NOTE: Keep a relatively high min-width for this so we don't obscure the end | |
| 273 * of the default text in relatively spacious languages (i.e. German). */ | |
| 274 min-width: 160px; | |
| 275 } | |
| 276 | |
| 277 input[type='text']:disabled { | |
| 278 color: #888; | |
| 279 } | |
| OLD | NEW |