1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
---
title: ':disabled'
slug: 'Web/CSS/:disabled'
tags:
- CSS
- Diseño
- Pseudo-clase
- Referencia
- Web
translation_of: 'Web/CSS/:disabled'
---
<div>{{CSSRef}}</div>
<p>La <a href="/en-US/docs/Web/CSS/Pseudo-classes">pseudo-clase</a> <code>:disabled</code> de <a href="/en-US/docs/Web/CSS">CSS</a> representa a cualquier elemento deshabilitado. Un elemento se encuentra deshabilitado si no puede ser activado (por ejemplo ser selecionado, hacer click en él o aceptar texto de entrada) ni aceptar el foco. El elemento tiene además un estado habilitado en el cual puede ser activado o recibir foco.</p>
<pre class="brush: css">/* Selecciona cualquier <input> deshabilitado */
input:disabled {
background: #ccc;
}</pre>
<h2 id="Sintaxis">Sintaxis</h2>
{{csssyntax}}
<h2 id="Ejemplo">Ejemplo</h2>
<p>Este ejemplo muestra un formulario de envío básico. Utiliza el evento <a href="/es/docs/Web/JavaScript">JavaScript</a> {{event("change")}} para permitir al usuario habilitar / deshabilitar los campos de facturación.</p>
<h3 id="HTML">HTML</h3>
<pre class="brush: html"><form action="#">
<fieldset id="shipping">
<legend>Dirección de Envío</legend>
<input type="text" placeholder="Nombre">
<input type="text" placeholder="Dirección">
<input type="text" placeholder="Código postal">
</fieldset>
<br>
<fieldset id="billing">
<legend>Dirección de facturación</legend>
<label for="billing_is_shipping">Igual que la dirección de envío:</label>
<input type="checkbox" id="billing-checkbox" checked>
<br>
<input type="text" placeholder="Nombre" disabled>
<input type="text" placeholder="Dirección" disabled>
<input type="text" placeholder="Código postal" disabled>
</fieldset>
</form></pre>
<h3 id="CSS">CSS</h3>
<pre class="brush: css">input[type="text"]:disabled {
background: #ccc;
}</pre>
<h3 id="JavaScript">JavaScript</h3>
<pre class="brush: js">// Esperar a que la página termine de cargarse
document.addEventListener('DOMContentLoaded', function () {
// Adjunte el detector de eventos `change` al checkbox
document.getElementById('billing-checkbox').onchange = toggleBilling;
}, false);
function toggleBilling() {
// Seleccione los campos de texto de facturación
var billingItems = document.querySelectorAll('#billing input[type="text"]');
// Alternar los campos de texto de facturación
for (var i = 0; i < billingItems.length; i++) {
billingItems[i].disabled = !billingItems[i].disabled;
}
}</pre>
<h3 id="Resultado">Resultado</h3>
<p>{{EmbedLiveSample('Ejemplo', 300, 250)}}</p>
<h2 id="Especificaciones">Especificaciones</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Especificación</th>
<th scope="col">Estado</th>
<th scope="col">Comentario</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('HTML WHATWG', '#selector-disabled', ':disabled')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td>Ningún cambio.</td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', '#selector-disabled', ':disabled')}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td>Define la semántica referente a HTML y los formularios.</td>
</tr>
<tr>
<td>{{SpecName('CSS4 Selectors', '#enableddisabled', ':disabled')}}</td>
<td>{{Spec2('CSS4 Selectors')}}</td>
<td>Ningún cambio.</td>
</tr>
<tr>
<td>{{SpecName('CSS3 Basic UI', '#pseudo-classes', ':disabled')}}</td>
<td>{{Spec2('CSS3 Basic UI')}}</td>
<td>Referencia a los selectores de Nivel 3.</td>
</tr>
<tr>
<td>{{SpecName('CSS3 Selectors', '#enableddisabled', ':disabled')}}</td>
<td>{{Spec2('CSS3 Selectors')}}</td>
<td>Define la pseudo clase pero no la semántica asociada..</td>
</tr>
</tbody>
</table>
<h2 id="Compatibilidad_con_navegadores">Compatibilidad con navegadores</h2>
<p>{{Compat("css.selectors.disabled")}}</p>
<h2 id="Ver_también">Ver también</h2>
<ul>
<li>
<p>{{Cssxref(":enabled")}}</p>
</li>
</ul>
|