Is there a function where I can give it an element and it'll give me its formatting context? I've already searched for such a function with no success. There's documentation for what makes an element a formatting context, but the conditions are complex and writing a function to find it myself would likely result in bugs.
Asked
Active
Viewed 67 times
1
-
Do you mean this? https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle – ssten Oct 29 '19 at 13:31
-
possible duplicate: https://stackoverflow.com/questions/30800379/how-can-i-tell-whether-an-element-establishes-a-new-block-formatting-context-usi – Fpunkt Oct 29 '19 at 13:32
-
@ssten No, that's how I would get the computed style of an element, which doesn't tell me if it counts as the formatting context for a child element down the line. – ProgramGamer Oct 29 '19 at 13:35
-
@flx Even if this is a duplicate, the question was never answered. – ProgramGamer Oct 29 '19 at 13:35
-
what is the point of your question? Since you make the page you should probably know what the formatting context is. You can always get the class name of the respective element or its CSS values und and make your decisions based on that. What do you expect from formatting context? – Fpunkt Oct 29 '19 at 13:46
-
@flk do not question the premise of my question please. The point is that I don't know beforehand what the formatting context is and need to determine it dynamically. I can't rely on class names or similar mechanisms. – ProgramGamer Oct 29 '19 at 13:50
-
The page @flx provided DID answer your question. No, there is not a function to do this, yes, you can write your own. Asking for the premise of the question is perfectly valid since there might be an easier way to solve your ultimate goal. Also, please be nice. It's early, not all of us have finished our coffee this morning. – Will Oct 29 '19 at 14:39