CSSStyleDeclaration-custom-properties.html 547 B

12345678910111213141516171819
  1. <!DOCTYPE html>
  2. <script src="../include.js"></script>
  3. <body></body>
  4. <script>
  5. test(() => {
  6. const div = document.createElement('div');
  7. div.style.setProperty("--redcolor", "red");
  8. const nested = document.createElement('div');
  9. nested.style["backgroundColor"] = "var(--redcolor)";
  10. nested.style["width"] = "100px";
  11. nested.style["height"] = "100px";
  12. div.appendChild(nested);
  13. document.body.appendChild(div);
  14. println(getComputedStyle(nested).backgroundColor);
  15. });
  16. </script>