1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-18 19:31:35 +02:00

Merge pull request #13745 from twbs/fix-13281

set not-allowed cursor on disabled radio+checkbox labels
This commit is contained in:
Mark Otto
2014-06-08 11:05:39 -07:00
3 changed files with 60 additions and 13 deletions

View File

@@ -2440,18 +2440,24 @@ input[type="month"].input-lg {
} }
input[type="radio"][disabled], input[type="radio"][disabled],
input[type="checkbox"][disabled], input[type="checkbox"][disabled],
.radio[disabled], input[type="radio"].disabled,
.radio-inline[disabled], input[type="checkbox"].disabled,
.checkbox[disabled],
.checkbox-inline[disabled],
fieldset[disabled] input[type="radio"], fieldset[disabled] input[type="radio"],
fieldset[disabled] input[type="checkbox"], fieldset[disabled] input[type="checkbox"] {
fieldset[disabled] .radio, cursor: not-allowed;
}
.radio-inline.disabled,
.checkbox-inline.disabled,
fieldset[disabled] .radio-inline, fieldset[disabled] .radio-inline,
fieldset[disabled] .checkbox,
fieldset[disabled] .checkbox-inline { fieldset[disabled] .checkbox-inline {
cursor: not-allowed; cursor: not-allowed;
} }
.radio.disabled label,
.checkbox.disabled label,
fieldset[disabled] .radio label,
fieldset[disabled] .checkbox label {
cursor: not-allowed;
}
.input-sm { .input-sm {
height: 30px; height: 30px;
padding: 5px 10px; padding: 5px 10px;

View File

@@ -207,7 +207,8 @@
{% endhighlight %} {% endhighlight %}
<h3>Checkboxes and radios</h3> <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> <h4>Default (stacked)</h4>
<div class="bs-example"> <div class="bs-example">
<form role="form"> <form role="form">
@@ -217,6 +218,12 @@
Option one is this and that&mdash;be sure to include why it's great Option one is this and that&mdash;be sure to include why it's great
</label> </label>
</div> </div>
<div class="checkbox disabled">
<label>
<input type="checkbox" value="" disabled>
Option two is disabled
</label>
</div>
<br> <br>
<div class="radio"> <div class="radio">
<label> <label>
@@ -230,6 +237,12 @@
Option two can be something else and selecting it will deselect option one Option two can be something else and selecting it will deselect option one
</label> </label>
</div> </div>
<div class="radio disabled">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
Option three is disabled
</label>
</div>
</form> </form>
</div><!-- /.bs-example --> </div><!-- /.bs-example -->
{% highlight html %} {% highlight html %}
@@ -239,6 +252,12 @@
Option one is this and that&mdash;be sure to include why it's great Option one is this and that&mdash;be sure to include why it's great
</label> </label>
</div> </div>
<div class="checkbox disabled">
<label>
<input type="checkbox" value="" disabled>
Option two is disabled
</label>
</div>
<div class="radio"> <div class="radio">
<label> <label>
@@ -252,6 +271,12 @@
Option two can be something else and selecting it will deselect option one Option two can be something else and selecting it will deselect option one
</label> </label>
</div> </div>
<div class="radio disabled">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
Option three is disabled
</label>
</div>
{% endhighlight %} {% endhighlight %}
<h4>Inline checkboxes and radios</h4> <h4>Inline checkboxes and radios</h4>

View File

@@ -247,19 +247,35 @@ input[type="month"] {
} }
// Apply same disabled cursor tweak as for inputs // 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. // Note: Neither radios nor checkboxes can be readonly.
input[type="radio"], input[type="radio"],
input[type="checkbox"], input[type="checkbox"] {
.radio,
.radio-inline,
.checkbox,
.checkbox-inline {
&[disabled], &[disabled],
&.disabled,
fieldset[disabled] & { fieldset[disabled] & {
cursor: not-allowed; cursor: not-allowed;
} }
} }
// These classes are used directly on <label>s
.radio-inline,
.checkbox-inline {
&.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 // Form control sizing