aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2014-06-08 11:05:39 -0700
committerMark Otto <[email protected]>2014-06-08 11:05:39 -0700
commit7231efabde1fb58576d7f05194218e888a9a70c8 (patch)
tree9b6371d074767075b349c26d82a2ba92fbfb7bde
parent5fd8ca9089aaaf9af2bf9282f3b95343db896eb9 (diff)
parentdd7ee517e4541cddf98b46feb8b35d1568ff2346 (diff)
downloadbootstrap-7231efabde1fb58576d7f05194218e888a9a70c8.tar.xz
bootstrap-7231efabde1fb58576d7f05194218e888a9a70c8.zip
Merge pull request #13745 from twbs/fix-13281
set not-allowed cursor on disabled radio+checkbox labels
-rw-r--r--dist/css/bootstrap.css20
-rw-r--r--docs/_includes/css/forms.html27
-rw-r--r--less/forms.less24
3 files changed, 59 insertions, 12 deletions
diff --git a/dist/css/bootstrap.css b/dist/css/bootstrap.css
index b172acc5b..87855926d 100644
--- a/dist/css/bootstrap.css
+++ b/dist/css/bootstrap.css
@@ -2440,18 +2440,24 @@ input[type="month"].input-lg {
}
input[type="radio"][disabled],
input[type="checkbox"][disabled],
-.radio[disabled],
-.radio-inline[disabled],
-.checkbox[disabled],
-.checkbox-inline[disabled],
+input[type="radio"].disabled,
+input[type="checkbox"].disabled,
fieldset[disabled] input[type="radio"],
-fieldset[disabled] input[type="checkbox"],
-fieldset[disabled] .radio,
+fieldset[disabled] input[type="checkbox"] {
+ cursor: not-allowed;
+}
+.radio-inline.disabled,
+.checkbox-inline.disabled,
fieldset[disabled] .radio-inline,
-fieldset[disabled] .checkbox,
fieldset[disabled] .checkbox-inline {
cursor: not-allowed;
}
+.radio.disabled label,
+.checkbox.disabled label,
+fieldset[disabled] .radio label,
+fieldset[disabled] .checkbox label {
+ cursor: not-allowed;
+}
.input-sm {
height: 30px;
padding: 5px 10px;
diff --git a/docs/_includes/css/forms.html b/docs/_includes/css/forms.html
index f2e29d6ff..95bb29c59 100644
--- a/docs/_includes/css/forms.html
+++ b/docs/_includes/css/forms.html
@@ -207,7 +207,8 @@
{% endhighlight %}
<h3>Checkboxes and radios</h3>
- <p>Checkboxes are for selecting one or several options in a list while radios are for selecting one option from many.</p>
+ <p>Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.</p>
+ <p>A checkbox or radio with the <code>disabled</code> attribute will be styled appropriately. To have the <code>&lt;label&gt;</code> for the checkbox or radio also display a "not-allowed" cursor when the user hovers over the label, add the <code>.disabled</code> class to your <code>.radio</code>, <code>.radio-inline</code>, <code>.checkbox</code>, <code>.checkbox-inline</code>, or <code>&lt;fieldset&gt;</code>.</p>
<h4>Default (stacked)</h4>
<div class="bs-example">
<form role="form">
@@ -217,6 +218,12 @@
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
+ <div class="checkbox disabled">
+ <label>
+ <input type="checkbox" value="" disabled>
+ Option two is disabled
+ </label>
+ </div>
<br>
<div class="radio">
<label>
@@ -230,6 +237,12 @@
Option two can be something else and selecting it will deselect option one
</label>
</div>
+ <div class="radio disabled">
+ <label>
+ <input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
+ Option three is disabled
+ </label>
+ </div>
</form>
</div><!-- /.bs-example -->
{% highlight html %}
@@ -239,6 +252,12 @@
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
+<div class="checkbox disabled">
+ <label>
+ <input type="checkbox" value="" disabled>
+ Option two is disabled
+ </label>
+</div>
<div class="radio">
<label>
@@ -252,6 +271,12 @@
Option two can be something else and selecting it will deselect option one
</label>
</div>
+<div class="radio disabled">
+ <label>
+ <input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
+ Option three is disabled
+ </label>
+</div>
{% endhighlight %}
<h4>Inline checkboxes and radios</h4>
diff --git a/less/forms.less b/less/forms.less
index cb8a74fa1..b678d44fc 100644
--- a/less/forms.less
+++ b/less/forms.less
@@ -247,19 +247,35 @@ input[type="month"] {
}
// Apply same disabled cursor tweak as for inputs
+// Some special care is needed because <label>s don't inherit their parent's `cursor`.
//
// Note: Neither radios nor checkboxes can be readonly.
input[type="radio"],
-input[type="checkbox"],
-.radio,
+input[type="checkbox"] {
+ &[disabled],
+ &.disabled,
+ fieldset[disabled] & {
+ cursor: not-allowed;
+ }
+}
+// These classes are used directly on <label>s
.radio-inline,
-.checkbox,
.checkbox-inline {
- &[disabled],
+ &.disabled,
fieldset[disabled] & {
cursor: not-allowed;
}
}
+// These classes are used on elements with <label> descendants
+.radio,
+.checkbox {
+ &.disabled,
+ fieldset[disabled] & {
+ label {
+ cursor: not-allowed;
+ }
+ }
+}
// Form control sizing