Ignore/override Surrounding / Inherited Css
I have this call to add HTML/CSS to an existing page: let div = document.createElement('div'); div.style.zIndex = 9999999; div.innerHTML = str; // some pre-defined HTML string doc
Solution 1:
Add a class
to elements which you want to reset..and then apply all:unset
to that class
...all:unset
Specifies that all the element's properties should be changed to their inherited
values if they inherit by default, or to their initial values if not.(It will ignore all the user agent style too.)
Stack Snippet
let p = document.createElement('p');
p.style.color = "red";
p.innerHTML = "Hello"; // some pre-defined HTML string
p.classList.add("reset");
document.body.insertBefore(p, document.body.firstChild);
p {
background: black;
}
.reset {
all: unset;
}
Post a Comment for "Ignore/override Surrounding / Inherited Css"