Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: css
csspositioningsimplicitylayout
Avoid manual offset math when CSS positioning suffices
Before computing pixel offsets in JS, confirm a CSS solution like position: fixed cannot achieve the same result more simply.
PR: hegnar-components · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | const offset = computeShadowDomOffset(el); // manual math |
| 2 | floating.style.top = `${rect.top + offset}px`; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codecss
| 1 | // rely on CSS positioning when it is sufficient |
| 2 | .floating { position: fixed; } |
Explanation (EN)
Objašnjenje (HR)