# Framework-specific Fix Guide This document explains specific fix techniques for each framework and styling method. --- ## Pure CSS / SCSS ### Fixing Layout Overflow ```css /* Before: Overflow occurs */ .container { width: 100%; } /* After: Control overflow */ .container { width: 100%; max-width: 100%; overflow-x: hidden; } ``` ### Text Clipping Prevention ```css /* Single line truncation */ .text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* Multi-line truncation */ .text-clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; } /* Word wrapping */ .text-wrap { word-wrap: break-word; overflow-wrap: break-word; hyphens: auto; } ``` ### Spacing Unification ```css /* Unify spacing with CSS custom properties */ :root { --spacing-xs: 0.25rem; --spacing-sm: 0.5rem; --spacing-md: 1rem; --spacing-lg: 1.5rem; --spacing-xl: 2rem; } .card { padding: var(--spacing-md); margin-bottom: var(--spacing-lg); } ``` ### Improving Contrast ```css /* Before: Insufficient contrast */ .text { color: #999999; background-color: #ffffff; } /* After: Meets WCAG AA standards */ .text { color: #595959; /* Contrast ratio 7:1 */ background-color: #ffffff; } ``` --- ## Tailwind CSS ### Layout Fixes ```jsx {/* Before: Overflow */}
{/* After: Overflow control */}
``` ### Text Clipping Prevention ```jsx {/* Single line truncation */}

Long text...

{/* Multi-line truncation */}

Long text...

{/* Allow wrapping */}

Long text...

``` ### Responsive Support ```jsx {/* Mobile-first responsive */}
Content
``` ### Spacing Unification (Tailwind Config) ```javascript // tailwind.config.js module.exports = { theme: { extend: { spacing: { '18': '4.5rem', '22': '5.5rem', }, }, }, } ``` ### Accessibility Improvements ```jsx {/* Add focus state */} {/* Improve contrast */}

{/* Changed from text-gray-500 */} Readable text

``` --- ## React + CSS Modules ### Fixes in Module Scope ```css /* Component.module.css */ /* Before */ .container { display: flex; } /* After: Add overflow control */ .container { display: flex; flex-wrap: wrap; overflow: hidden; max-width: 100%; } ``` ### Component-side Fixes ```jsx // Component.jsx import styles from './Component.module.css'; // Before
// After: Add conditional class
``` --- ## styled-components / Emotion ### Style Fixes ```jsx // Before const Container = styled.div` width: 100%; `; // After const Container = styled.div` width: 100%; max-width: 100%; overflow-x: hidden; @media (max-width: 768px) { padding: 1rem; } `; ``` ### Responsive Support ```jsx const Card = styled.div` display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; @media (max-width: 1024px) { grid-template-columns: repeat(2, 1fr); } @media (max-width: 640px) { grid-template-columns: 1fr; gap: 1rem; } `; ``` ### Consistency with Theme ```jsx // theme.js export const theme = { colors: { primary: '#2563eb', text: '#1f2937', textLight: '#4b5563', // Improved contrast }, spacing: { sm: '0.5rem', md: '1rem', lg: '1.5rem', }, }; // Usage const Text = styled.p` color: ${({ theme }) => theme.colors.text}; margin-bottom: ${({ theme }) => theme.spacing.md}; `; ``` --- ## Vue (Scoped Styles) ### Fixing Scoped Styles ```vue ``` ### Deep Selectors (Affecting Child Components) ```vue ``` --- ## Next.js / App Router ### Global Style Fixes ```css /* app/globals.css */ :root { --foreground: #171717; --background: #ffffff; } /* Prevent layout overflow */ html, body { max-width: 100vw; overflow-x: hidden; } /* Prevent image overflow */ img { max-width: 100%; height: auto; } ``` ### Fixes in Layout Components ```tsx // app/layout.tsx export default function RootLayout({ children }) { return (
{/* Header */}
{children}
); } ``` --- ## Common Patterns ### Fixing Flexbox Layout Issues ```css /* Before: Items overflow */ .flex-container { display: flex; gap: 1rem; } /* After: Wrap and size control */ .flex-container { display: flex; flex-wrap: wrap; gap: 1rem; } .flex-item { flex: 1 1 300px; /* grow, shrink, basis */ min-width: 0; /* Prevent flexbox overflow issues */ } ``` ### Fixing Grid Layout Issues ```css /* Before: Fixed column count */ .grid-container { display: grid; grid-template-columns: repeat(4, 1fr); } /* After: Auto-adjust */ .grid-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; } ``` ### Organizing z-index ```css /* Systematize z-index */ :root { --z-dropdown: 100; --z-sticky: 200; --z-modal-backdrop: 300; --z-modal: 400; --z-tooltip: 500; } .modal { z-index: var(--z-modal); } ``` ### Adding Focus States ```css /* Add focus state to all interactive elements */ button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; } /* Customize focus ring */ .custom-focus:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.5); } ``` --- ## Debugging Techniques ### Visualizing Element Boundaries ```css /* Use only during development */ * { outline: 1px solid red !important; } ``` ### Detecting Overflow ```javascript // Run in console to detect overflow elements document.querySelectorAll('*').forEach(el => { if (el.scrollWidth > el.clientWidth) { console.log('Horizontal overflow:', el); } if (el.scrollHeight > el.clientHeight) { console.log('Vertical overflow:', el); } }); ``` ### Checking Contrast Ratio ```javascript // Use Chrome DevTools Lighthouse or axe DevTools // Or check at the following site: // https://webaim.org/resources/contrastchecker/ ```