Fix global CSS bug silently disabling all Tailwind margin/padding utilities
index.css had a hand-written reset (`*, *::before, *::after { margin: 0;
padding: 0; box-sizing: border-box; }`) left over from before Tailwind was
added, sitting outside any `@layer` block. Per the CSS Cascade Layers spec,
unlayered rules always beat layered rules regardless of selector
specificity — since every Tailwind utility class lives inside `@layer
utilities`, this one `*`-selector rule was silently overriding every
single margin/padding utility (p-*, m-*, mx-auto, etc.) across the entire
app. Other properties (colors, borders, gap) weren't affected, which is
why this went unnoticed through the whole Tailwind migration — only
spacing/centering was silently broken, not colors or general layout.
Tailwind's own preflight (already loaded via `@import "tailwindcss"`,
correctly placed inside `@layer base`) provides the identical reset, so
the duplicate unlayered copy was simply deleted.
Also fixed two smaller, related issues found while investigating: an
inline `style={{ maxWidth: '100vw' }}` on Login/Register's auth-card
overrode its CSS class's `max-width: 400px`, stretching it to near full
viewport width on screens wider than ~400px (invisible on mobile, obvious
on laptop/desktop — probably what originally looked like "responsive
wasn't fixed"). And BacktestPage.tsx, unlike every other page, rendered
its `mx-auto`-centered container as a direct child of #root (which has
`display: flex; flex-direction: column`), so flexbox's default
align-items: stretch overrode the centering; wrapped it in the same
min-h-screen container pattern every other page already uses.
Verified via direct getComputedStyle()/getBoundingClientRect() measurement
(screenshots in this environment don't reliably reflect true layout) —
margin-inline resolved to 0px before the fix, 183px (correctly centered)
after. Frontend build clean, 170 backend tests unaffected (CSS-only change).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@ export default function LoginPage() {
|
||||
|
||||
return (
|
||||
<div className="auth-page">
|
||||
<div className="auth-card" style={{ maxWidth: '100vw', boxSizing: 'border-box' }}>
|
||||
<div className="auth-card">
|
||||
<h1>{t('login.title')}</h1>
|
||||
<h2>{t('login.subtitle')}</h2>
|
||||
{error && <div className="error-message">{error}</div>}
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function RegisterPage() {
|
||||
|
||||
return (
|
||||
<div className="auth-page">
|
||||
<div className="auth-card" style={{ maxWidth: '100vw', boxSizing: 'border-box' }}>
|
||||
<div className="auth-card">
|
||||
<h1>Trading Portal</h1>
|
||||
<h2>Create Account</h2>
|
||||
{error && <div className="error-message">{error}</div>}
|
||||
|
||||
@@ -161,7 +161,8 @@ export default function BacktestPage() {
|
||||
}, [exchange]);
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-[1000px] bg-bg-primary p-5 text-text-primary">
|
||||
<div className="min-h-screen bg-bg-primary">
|
||||
<div className="mx-auto max-w-[1000px] p-5 text-text-primary">
|
||||
<h1 className="text-2xl font-bold text-text-heading">📊 {t('Backtest')}</h1>
|
||||
|
||||
<div className="mb-5 mt-3 flex gap-1">
|
||||
@@ -181,6 +182,7 @@ export default function BacktestPage() {
|
||||
symbols={symbols} tradeSize={tradeSize} setTradeSize={setTradeSize} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,14 +64,13 @@
|
||||
background-color: var(--bg-primary);
|
||||
}
|
||||
|
||||
/* --- Global Reset --- */
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
/* Global box-sizing/margin/padding reset is handled by Tailwind's own
|
||||
preflight (inside @layer base, from `@import "tailwindcss"` above).
|
||||
A hand-written unlayered copy of the same reset used to live here —
|
||||
CSS Cascade Layers give ANY unlayered rule priority over ALL layered
|
||||
rules regardless of selector specificity, so that unlayered `* { margin:
|
||||
0; padding: 0 }` was silently overriding every single Tailwind margin/
|
||||
padding utility class (p-*, m-*, mx-auto, etc.) app-wide. Removed. */
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
|
||||
Reference in New Issue
Block a user