From 1109132f09d75da9a28b649c7677bb6ce07c40c0 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:45 -0500 Subject: initial commit --- .../es/web/api/cssstylesheet/deleterule/index.html | 21 ++++ files/es/web/api/cssstylesheet/index.html | 64 +++++++++++ .../es/web/api/cssstylesheet/insertrule/index.html | 119 +++++++++++++++++++++ .../es/web/api/cssstylesheet/ownerrule/index.html | 19 ++++ 4 files changed, 223 insertions(+) create mode 100644 files/es/web/api/cssstylesheet/deleterule/index.html create mode 100644 files/es/web/api/cssstylesheet/index.html create mode 100644 files/es/web/api/cssstylesheet/insertrule/index.html create mode 100644 files/es/web/api/cssstylesheet/ownerrule/index.html (limited to 'files/es/web/api/cssstylesheet') diff --git a/files/es/web/api/cssstylesheet/deleterule/index.html b/files/es/web/api/cssstylesheet/deleterule/index.html new file mode 100644 index 0000000000..f11a905d98 --- /dev/null +++ b/files/es/web/api/cssstylesheet/deleterule/index.html @@ -0,0 +1,21 @@ +--- +title: Stylesheet.deleteRule +slug: Web/API/CSSStyleSheet/deleteRule +translation_of: Web/API/CSSStyleSheet/deleteRule +--- +

{{ ApiRef() }}

+

Resumen

+

El método deleteRule elimina una regla de la hoja de estilos actual.

+

Sintaxis

+
stylesheet.deleteRule(index)
+
+

Parámetros

+ +

Ejemplo

+
 myStyles.deleteRule(0);
+
+

Especificación

+

deleteRule

+

{{ languages( { "pl": "pl/DOM/stylesheet.deleteRule" } ) }}

diff --git a/files/es/web/api/cssstylesheet/index.html b/files/es/web/api/cssstylesheet/index.html new file mode 100644 index 0000000000..f9781136ae --- /dev/null +++ b/files/es/web/api/cssstylesheet/index.html @@ -0,0 +1,64 @@ +--- +title: CSSStyleSheet +slug: Web/API/CSSStyleSheet +translation_of: Web/API/CSSStyleSheet +--- +

{{ ApiRef() }}

+

 

+

This section describes the CSSStyleSheet object, which represents a single CSS stylesheet.

+

A CSS stylesheet consists of CSS rules, each of them can be manipulated through its CSSRule object. The stylesheet object itself lets you examine and modify the stylesheet, including its list of rules.

+

You can get the list of stylesheets for a given document using the document.styleSheets property.

+

Properties

+
+
+ stylesheet.cssRules
+
+ Returns all of the CSS rules in the stylesheet as an array.
+
+ stylesheet.disabled
+
+ This property indicates whether the current stylesheet has been applied or not.
+
+ stylesheet.href
+
+ Returns the location of the stylesheet.
+
+ stylesheet.media
+
+ Specifies the intended destination medium for style information.
+
+ stylesheet.ownerNode
+
+ Returns the node that associates this style sheet with the document.
+
+ stylesheet.ownerRule
+
+ If this style sheet comes from an @import rule, the ownerRule property will contain the CSSImportRule.
+
+ stylesheet.parentStyleSheet
+
+ Returns the stylesheet that is including this one, if any.
+
+ stylesheet.title
+
+ Returns the advisory title of the current style sheet.
+
+ stylesheet.type
+
+ Specifies the style sheet language for this style sheet.
+
+

Methods

+
+
+ stylesheet.deleteRule
+
+ Deletes a rule from the stylesheet.
+
+ stylesheet.insertRule
+
+ Inserts a new style rule into the current style sheet.
+
+

Specification

+

DOM Level 2 Style Sheets: StyleSheet

+

DOM Level 2 CSS: CSSStyleSheet

+

{{ languages( { "pl": "pl/DOM/stylesheet" } ) }}

diff --git a/files/es/web/api/cssstylesheet/insertrule/index.html b/files/es/web/api/cssstylesheet/insertrule/index.html new file mode 100644 index 0000000000..ef0f3e522d --- /dev/null +++ b/files/es/web/api/cssstylesheet/insertrule/index.html @@ -0,0 +1,119 @@ +--- +title: CSSStyleSheet.insertRule() +slug: Web/API/CSSStyleSheet/insertRule +tags: + - CSSStyleSheet +translation_of: Web/API/CSSStyleSheet/insertRule +--- +
+ {{APIRef}}
+

El método CSSStyleSheet.insertRule() inserta una nueva regla de estilo en la actual hoja de estilos.

+

Para conjuntos de reglas ésta contiene tanto al selector como la declaración de estilo. Para reglas-arroba, ésta especifica tanto al identificador-arroba como como al contenido de la regla. Si se asignan varias reglas en el  {{domxref("DOMString")}} como parámetro se dispara una  {{domxref("DOMException")}} con el código SYNTAX_ERR.

+

Syntax

+
stylesheet.insertRule(regla, índice)
+

Parameters

+ +

Ejemplos

+

Ejemplo 1

+
// Insertar una nueva regla al principio de mi hoja de estilos
+myStyle.insertRule("#blanc { color: white }", 0);
+
+

Example 2

+
/**
+ * Agregar una regla de hoja de estilos al documento(sin embargo, una mejor práctica puede ser
+ * cambiar las clases dinamicamente, así se mantiene la información de estilo en
+ * hojas de estilo genuinas (evitando agregar elementos extras al DOM))
+ * Note que se necesita una matriz para las declaraciones y reglas ya que ECMAScript
+ * no proporciona un orden de iteración predecible y como CSS
+ * depende del orden(i.e., es cascada); aquellos sin necesidad de
+ * reglas en cascada podrían construir una API basada en objetos de acceso más amigable.
+ * @param {Matriz} reglas. Acepta una matriz de  declaraciones JSON-encoded
+ * @example
+addStylesheetRules([
+  ['h2', // Acepta un segundo argumento como una matriz de matrices
+    ['color', 'red'],
+    ['background-color', 'green', true] // 'true' para reglas !important
+  ],
+  ['.myClass', ['background-color', 'yellow']
+  ]
+]);
+ */
+function addStylesheetRules (decls) {
+  var styleEl = document.createElement('style');
+  document.head.appendChild(styleEl);
+  // Aparentemente ¿alguna versión de Safari necesita la siguiente linea? No lo sé.
+  styleEl.appendChild(document.createTextNode(''));
+  var s = styleEl.sheet;
+  for (var i=0, rl = rules.length; i < rl; i++) {
+    var j = 1, rule = rules[i], selector = decl[0], propStr = '';
+    // Si el segundo argumento de una regla es una matriz de matrices, corrijamos nuestras variables.
+    if (Object.prototype.toString.call(rule[1][0]) === '[object Array]') {
+      rule = rule[1];
+      j = 0;
+    }
+    for (var pl=rule.length; j < pl; j++) {
+      var prop = rule[j];
+      propStr += prop[0] + ':' + prop[1] + (prop[2] ? ' !important' : '') + ';\n';
+    }
+    s.insertRule(selector + '{' + propStr + '}', s.cssRules.length);
+  }
+}
+

Specification

+ +

Browser compatibility

+

{{ CompatibilityTable() }}

+
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}8{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+

See also

+ diff --git a/files/es/web/api/cssstylesheet/ownerrule/index.html b/files/es/web/api/cssstylesheet/ownerrule/index.html new file mode 100644 index 0000000000..cd8c302ce3 --- /dev/null +++ b/files/es/web/api/cssstylesheet/ownerrule/index.html @@ -0,0 +1,19 @@ +--- +title: Stylesheet.ownerRule +slug: Web/API/CSSStyleSheet/ownerRule +--- +

{{ ApiRef() }}

+

Resumen

+

Si esta hoja de estilos viene de una regla @import, la propiedad ownerRule contendrá la CSSImportRule.

+

Sintaxis

+
rule = stylesheet.ownerRule
+
+

Parámetros

+ +

Notas

+

Ten en cuenta que si el valor de la propiedad ownerNode en el elemento STYLE actual es NULL, el valor ownerRule devolverá !!TODO!! y viceversa.

+

Specification

+

ownerRule

+

{{ languages( { "pl": "pl/DOM/stylesheet.ownerRule" } ) }}

-- cgit v1.2.3-54-g00ecf