The value of the background shorthand property expands incorrectly when trying to call HTMLElement.style
P粉269530053
P粉269530053 2023-09-03 21:10:48
0
2
319
<p>In the element's style, I have some inline CSS declarations, including a shorthand declaration for the background</p> <pre class="brush:php;toolbar:false;"><style> :root{ --bg-white: rgba(255, 255, 255, 0); } </style> <div style="background: var(--bg-white); ... "></div></pre> <p>But when iterating over HTMLElement.style, the shorthand properties look like they are incorrectly expanded</p> <pre class="brush:php;toolbar:false;">for (const declaration of Array.from(target.style)) { const value = target.style.getPropertyValue(declaration) console.log(`${declaration}: ${value}`) }</pre> <p>This should print out <code>background-color: var(--bg-white)</code> according to the HTMLElement.style documentation on MDN, but I get <code>background-color: ' '</code> </p> <blockquote> <p>Expanded abbreviation properties. If style="border-top: 1px Solid black" is set, the normal properties (border-top-color, border-top-style and border-top-width) are set. </p> </blockquote> <p>Has anyone encountered this situation? </p>
P粉269530053
P粉269530053

reply all(2)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!