|
1 | | -# Styles and classes |
| 1 | +# Estilos y clases |
2 | 2 |
|
3 | 3 | Before we get into JavaScript's ways of dealing with styles and classes -- here's an important rule. Hopefully it's obvious enough, but we still have to mention it. |
4 | 4 |
|
@@ -285,19 +285,20 @@ But `getComputedStyle` does not give access to that color, because otherwise an |
285 | 285 | JavaScript may not see the styles applied by `:visited`. And also, there's a limitation in CSS that forbids applying geometry-changing styles in `:visited`. That's to guarantee that there's no side way for an evil page to test if a link was visited and hence to break the privacy. |
286 | 286 | ``` |
287 | 287 |
|
288 | | -## Summary |
| 288 | +## Resumen |
289 | 289 |
|
290 | | -To manage classes, there are two DOM properties: |
| 290 | +Para manejar clases, hay dos propiedades del DOM: |
291 | 291 |
|
292 | | -- `className` -- the string value, good to manage the whole set of classes. |
293 | | -- `classList` -- the object with methods `add/remove/toggle/contains`, good for individual classes. |
| 292 | +- `className` -- el valor de la cadena, perfecto para manejar todo el conjunto de clases. |
| 293 | +- `classList` -- el objeto con métodos `add/remove/toggle/contains`, perfecto para clases invidivuales. |
294 | 294 |
|
295 | | -To change the styles: |
| 295 | +Para cambiar los estilos: |
296 | 296 |
|
297 | | -- The `style` property is an object with camelCased styles. Reading and writing to it has the same meaning as modifying individual properties in the `"style"` attribute. To see how to apply `important` and other rare stuff -- there's a list of methods at [MDN](mdn:api/CSSStyleDeclaration). |
| 297 | +- La propiedad `style` es un objecto con los estilos en `camelcase`. |
| 298 | +Leer y escribir tiene el mismo significado que modificar propiedades individuales en el atributo `"style"`. Para ver como aplicar `important` y otras cosas raras, hay una lista de métodos en [MDN](mdn:api/CSSStyleDeclaration). |
298 | 299 |
|
299 | | -- The `style.cssText` property corresponds to the whole `"style"` attribute, the full string of styles. |
| 300 | +- La propiedad `style.cssText` corresponde a todo el atributo `"style"`, la cadena completa de estilos. |
300 | 301 |
|
301 | | -To read the resolved styles (with respect to all classes, after all CSS is applied and final values are calculated): |
| 302 | +Para leer los estilos resueltos (con respecto a todas las clases, después de que se aplica todo el `css` se calculan los valores finales): |
302 | 303 |
|
303 | | -- The `getComputedStyle(elem, [pseudo])` returns the style-like object with them. Read-only. |
| 304 | +- El método `getComputedStyle(elem, [pseudo])` retorna el objeto de estilo con ellos (solo lectura). |
0 commit comments