Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5107)

Unified Diff: chrome/browser/resources/shared/css/widgets.css

Issue 9609023: css hack n' slash, continued: New styles for checkboxes and radios. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/shared/css/widgets.css
diff --git a/chrome/browser/resources/shared/css/button.css b/chrome/browser/resources/shared/css/widgets.css
similarity index 53%
rename from chrome/browser/resources/shared/css/button.css
rename to chrome/browser/resources/shared/css/widgets.css
index 31fb09cf487f5cca8b62b87c123c49347c521a4a..7b7c1203677b76a28148e154e5ffaef8f9841742 100644
--- a/chrome/browser/resources/shared/css/button.css
+++ b/chrome/browser/resources/shared/css/widgets.css
@@ -3,46 +3,54 @@
* found in the LICENSE file.
*/
+/* This file defines styles for form controls. The order of rule blocks is
+ * important as there are some rules with equal specificity that rely on order
+ * 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
+ */
+
/* Default state **************************************************************/
button:not(.custom-appearance):not(.link-button),
input[type='button']:not(.custom-appearance):not(.link-button),
input[type='submit']:not(.custom-appearance):not(.link-button),
-select {
+select,
+input[type='checkbox'],
+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
+ -webkit-appearance: none;
-webkit-user-select: none;
+ background-image: -webkit-linear-gradient(#ededed, #ededed 38%, #dedede);
border-radius: 2px;
border: 1px solid rgba(0, 0, 0, 0.25);
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08),
inset 0 1px 2px rgba(255, 255, 255, 0.75);
color: #444;
font: inherit;
- height: 2em;
margin: 0 1px 0 0;
- min-width: 4em;
text-shadow: 0 1px 0 rgb(240, 240, 240);
}
button:not(.custom-appearance):not(.link-button),
input[type='button']:not(.custom-appearance):not(.link-button),
+input[type='submit']:not(.custom-appearance):not(.link-button),
+select {
+ height: 2em;
+ min-width: 4em;
+}
+
+button:not(.custom-appearance):not(.link-button),
+input[type='button']:not(.custom-appearance):not(.link-button),
input[type='submit']:not(.custom-appearance):not(.link-button) {
-webkit-padding-end: 10px;
-webkit-padding-start: 10px;
- background-image:
- -webkit-gradient(linear, left top, left bottom,
- color-stop(0, rgb(237, 237, 237)),
- color-stop(0.38, rgb(237, 237, 237)),
- color-stop(1, rgb(222, 222, 222)));
}
select {
-webkit-appearance: none;
-webkit-padding-end: 20px;
-webkit-padding-start: 6px;
+ /* OVERRIDE */
background-image: url('../images/select.png'),
- -webkit-gradient(linear, left top, left bottom,
- color-stop(0, rgb(237, 237, 237)),
- color-stop(0.38, rgb(237, 237, 237)),
- color-stop(1, rgb(222, 222, 222)));
+ -webkit-linear-gradient(#ededed, #ededed 38%, #dedede);
background-position: right center;
background-repeat: no-repeat;
overflow: hidden;
@@ -55,62 +63,84 @@ html[dir='rtl'] select {
background-position: center left;
}
-/* Hover **********************************************************************/
+input[type='checkbox'] {
+ border-radius: 2px;
+ height: 13px;
+ position: relative;
+ top: 2px;
+ width: 13px;
+}
-button:not(.custom-appearance):not(.link-button):enabled:hover,
-input[type='button']:not(.custom-appearance):not(.link-button):enabled:hover,
-input[type='submit']:not(.custom-appearance):not(.link-button):enabled:hover {
- background-image: -webkit-gradient(linear, left top, left bottom,
- color-stop(0, rgb(240, 240, 240)),
- color-stop(0.38, rgb(240, 240, 240)),
- color-stop(1, rgb(224, 224, 224)));
+input[type='radio'] {
+ border-radius: 100%;
+ height: 15px;
+ position: relative;
+ width: 15px;
}
-select:enabled:hover {
- background-image: url('../images/select.png'),
- -webkit-gradient(linear, left top, left bottom,
- color-stop(0, rgb(237, 237, 237)),
- color-stop(0.38, rgb(237, 237, 237)),
- color-stop(1, rgb(222, 222, 222)));
+/* Checked ********************************************************************/
+
+input[type='checkbox']:checked::before {
+ -webkit-user-select: none;
+ content: url('../images/check.png');
}
+input[type='radio']:checked::before {
+ background-color: #666;
+ border-radius: 100%;
+ content: '';
+ display: inline-block;
+ height: 7px;
+ left: 3px;
+ position: absolute;
+ top: 3px;
+ width: 7px;
+}
+
+html[dir='rtl'] input[type='radio']:checked::before {
+ right: 0;
+}
+
+/* Hover **********************************************************************/
+
button:not(.custom-appearance):not(.link-button):enabled:hover,
input[type='button']:not(.custom-appearance):not(.link-button):enabled:hover,
input[type='submit']:not(.custom-appearance):not(.link-button):enabled:hover,
-select:enabled:hover {
+select:enabled:hover,
+input[type='checkbox']:enabled:hover,
+input[type='radio']:enabled:hover {
+ background-image: -webkit-linear-gradient(#f0f0f0, #f0f0f0 38%, #e0e0e0);
border-color: rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12),
inset 0 1px 2px rgba(255, 255, 255, 0.95);
color: black;
}
-/* Active *********************************************************************/
-
-button:not(.custom-appearance):not(.link-button):enabled:active,
-input[type='button']:not(.custom-appearance):not(.link-button):enabled:active,
-input[type='submit']:not(.custom-appearance):not(.link-button):enabled:active {
- background-image: -webkit-gradient(linear, left top, left bottom,
- color-stop(0, rgb(231, 231, 231)),
- color-stop(0.38, rgb(231, 231, 231)),
- color-stop(1, rgb(215, 215, 215)));
-}
-
-select:enabled:active {
+select:enabled:hover {
+ /* OVERRIDE */
background-image: url('../images/select.png'),
- -webkit-gradient(linear, left top, left bottom,
- color-stop(0, rgb(231, 231, 231)),
- color-stop(0.38, rgb(231, 231, 231)),
- color-stop(1, rgb(215, 215, 215)));
+ -webkit-linear-gradient(#f0f0f0, #f0f0f0 38%, #e0e0e0);
}
+/* Active *********************************************************************/
+
button:not(.custom-appearance):not(.link-button):enabled:active,
input[type='button']:not(.custom-appearance):not(.link-button):enabled:active,
input[type='submit']:not(.custom-appearance):not(.link-button):enabled:active,
-select:enabled:active {
+select:enabled:active,
+input[type='checkbox']:enabled:active,
+input[type='radio']:enabled:active {
+ background-image: -webkit-linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7);
box-shadow: none;
text-shadow: none;
}
+select:enabled:active {
+ /* OVERRIDE */
+ background-image: url('../images/select.png'),
+ -webkit-linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7);
+}
+
/* Disabled *******************************************************************/
button:not(.custom-appearance):not(.link-button):disabled,
@@ -123,17 +153,21 @@ select:disabled {
select:disabled {
background-image: url('../images/disabled_select.png'),
- -webkit-gradient(linear, left top, left bottom,
- color-stop(0, rgb(237, 237, 237)),
- color-stop(0.38, rgb(237, 237, 237)),
- color-stop(1, rgb(222, 222, 222)));
+ -webkit-linear-gradient(#ededed, #ededed 38%, #dedede);
+}
+
+input[type='checkbox']:disabled,
+input[type='radio']:disabled {
+ opacity: .75;
}
/* Focus **********************************************************************/
button:not(.custom-appearance):not(.link-button):focus,
input[type='submit']:not(.custom-appearance):focus,
-input[type='text']:not(.custom-appearance):focus,
+input[type='text']:focus,
+input[type='checkbox']:focus,
+input[type='radio']:focus,
select:focus {
-webkit-transition: border-color 200ms;
/* We use border color because it follows the border radius (unlike outline).
@@ -176,3 +210,70 @@ input[type='search']:not(.custom-appearance):focus {
cursor: default;
text-decoration: none;
}
+
+/* Checkbox/radio helpers ******************************************************
+ *
+ * .checkbox and .radio classes wrap labels. Checkboxes and radios should use
+ * 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.
+ *
+ * <div class="checkbox">
+ * <label>
+ * <input type="checkbox"></input>
+ * <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
+ * </label>
+ * </div>
+ */
+
+.checkbox,
+.radio {
+ margin: 0.45em 0;
+}
+
+.checkbox label,
+.radio label {
+ color: #444;
+ /* 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.
+ display: -webkit-inline-box;
+}
+
+.checkbox label input ~ span,
+.radio label input ~ span {
+ -webkit-margin-start: 0.4em;
+ /* Make sure long spans wrap at the same horizontal position they start. */
+ display: block;
+}
+
+.checkbox label:hover,
+.radio label:hover {
+ color: black;
+}
+
+label > input[type=checkbox]:disabled ~ span,
+label > input[type=radio]:disabled ~ span {
+ color: #999;
+}
+
+/* Text inputs ****************************************************************/
+/* TODO(estade): add more types here? */
Dan Beam 2012/03/06 04:47:07 moar types?!
+input[type='password'],
+input[type='search'],
+input[type='text'],
+input[type='url'],
+input:not([type]) {
+ border: 1px solid #bfbfbf;
+ 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
+ font: inherit;
+ height: 2em;
+ margin: 0;
+ padding: 3px;
+}
+
+input[type='search'] {
+ /* NOTE: Keep a relatively high min-width for this so we don't obscure the end
+ * of the default text in relatively spacious languages (i.e. German). */
+ min-width: 160px;
+}
+
+input[type='text']:disabled {
+ color: #888;
+}

Powered by Google App Engine
This is Rietveld 408576698