blob: 1c2ec69c341a05232c754f0832b1f8c87cb12801 (
plain)
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
|
---
title: Selectores de hermanos generales
slug: Web/CSS/General_sibling_combinator
tags:
- CSS
- NeedsMobileBrowserCompatibility
- Referencia CSS
- Selectores
translation_of: Web/CSS/General_sibling_combinator
original_slug: Web/CSS/Selectores_hermanos_generales
---
<div><span class="s1">{{CSSRef("Selectors")}}</span></div>
<h2 id="Summary" name="Summary">Resumen</h2>
<p>El combinador <code>~</code> separa dos selectores y selecciona el segundo elemento sólo si está precedido por el primero y ambos comparten un padre común.</p>
<h2 id="Syntax" name="Syntax">Sintaxis</h2>
<pre class="syntaxbox">elemento ~ elemento { <em>estilos</em> }
</pre>
<h2 id="Example" name="Example">Ejemplo</h2>
<pre class="brush: css">p ~ span {
color: red;
}</pre>
<pre class="brush: html"><span>Este span no es rojo.</span>
<p>Aquí hay un párrafo.</p>
<code>Aquí hay algo de código.</code>
<span>Aquí hay un span. Es rojo porque va precedido de un párrafo y ambos comparten el mismo padre.</span></pre>
<p>{{ EmbedLiveSample('Example', 320, 150) }}</p>
<h2 id="Specifications" name="Specifications">Especificaciones</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Especificación</th>
<th scope="col">Estado</th>
<th scope="col">Comentarios</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ SpecName('CSS4 Selectors', '#general-sibling-combinators', 'following-sibling combinator') }}</td>
<td>{{Spec2('CSS4 Selectors')}}</td>
<td> </td>
</tr>
<tr>
<td>{{ SpecName('CSS3 Selectors', '#general-sibling-combinators', 'general sibling combinator') }}</td>
<td>{{Spec2('CSS3 Selectors')}}</td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="Compatibilidad_entre_navegadores">Compatibilidad entre navegadores</h2>
{{Compat("css.selectors.general_sibling")}}
<h2 id="Ver_también">Ver también</h2>
<p> </p>
<ul>
<li><a href="/en-US/docs/Web/CSS/Adjacent_sibling_selectors">Selectores de hermanos adyacentes</a></li>
</ul>
|