From 4b1a9203c547c019fc5398082ae19a3f3d4c3efe Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:15 -0500 Subject: initial commit --- files/ca/web/css/_doublecolon_selection/index.html | 160 +++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 files/ca/web/css/_doublecolon_selection/index.html (limited to 'files/ca/web/css/_doublecolon_selection/index.html') diff --git a/files/ca/web/css/_doublecolon_selection/index.html b/files/ca/web/css/_doublecolon_selection/index.html new file mode 100644 index 0000000000..62b5e25619 --- /dev/null +++ b/files/ca/web/css/_doublecolon_selection/index.html @@ -0,0 +1,160 @@ +--- +title: '::selection' +slug: 'Web/CSS/::selection' +tags: + - CSS + - Layout + - Pseudo-element + - Reference +translation_of: 'Web/CSS/::selection' +--- +
{{CSSRef}}
+ +

El pseudo-element CSS ::selection aplica estils a la part d'un document que l'usuari ha ressaltat (com ara amb el ratolí).

+ +
::selection {
+  color: gold;
+  background: red;
+}
+ +

Només un petit subconjunt de propietats CSS es pot utilitzar amb el pseudo-element ::selection:

+ + + +

Tingueu en compte que, en particular, s'ignora {{cssxref("background-image")}}.

+ +

Sintaxi

+ +
/* Firefox syntax */
+::-moz-selection
+
+{{csssyntax}}
+
+ +

Exemple

+ +

HTML

+ +
<div>This text has special styles when you highlight it.</div>
+<p>Also try selecting text in this paragraph.</p>
+ +

CSS

+ +
/* Make selected text gold on a red background */
+::-moz-selection {
+  color: gold;
+  background: red;
+}
+
+::selection {
+  color: gold;
+  background: red;
+}
+
+/* Make selected text in a paragraph white on a blue background */
+p::-moz-selection {
+  color: white;
+  background: blue;
+}
+
+p::selection {
+  color: white;
+  background: blue;
+}
+ +

Resultat

+ +

{{EmbedLiveSample('Example')}}

+ +

Especificacions

+ + + + + + + + + + + + + + + + +
EspecificacióEstatComentari
{{SpecName('CSS4 Pseudo-Elements', '#selectordef-selection', '::selection')}}{{Spec2('CSS4 Pseudo-Elements')}}Definició inicial.
+ +
+

Nota: Tot i que ::selection estava present en els esborranys de CSS Selectors Nivell 3, es va eliminar durant la fase de Recomanació de Candidats perquè el seu comportament no era suficientment especificat (especialment amb elements niats) i no es va aconseguir la interoperabilitat (basada en una discussió en la llista de correu d'Estil W3C). El pseudo-element ::selection ha estat retornat a Pseudo-Elements Nivell 4.

+
+ + + +
+

Nota: text-shadow en ::selection és compatible amb Chrome, Safari i Firefox 17+.

+
+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
DescripcióChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic1{{CompatVersionUnknown}}1.0 {{property_prefix("-moz")}}[1]99.51.1
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
DescripcióAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

[1] Gecko actualment només és compatible amb la versió prefixada ::-moz-selection. Serà sense prefix en {{bug(509958)}}.

-- cgit v1.2.3-54-g00ecf