To ensure that your headings (h1, h2, h3) and other text elements scale appropriately within your responsive containers, you can use CSS with relative units like rem and vw (viewport width). Additionally, you can use CSS clamps to set minimum and maximum font sizes to ensure readability across different screen sizes.
Here’s how you can update your global.css to achieve this, along with adjustments to your TextSection component and page.tsx to ensure consistency:
Updated global.css
:root {
--background: #ffffff; /* Default background color */
--foreground: #000000; /* Default text color */
/* Fluid typography scales */
--font-size-h1: clamp(2rem, 5vw, 3.5rem);
--font-size-h2: clamp(1.75rem, 4vw, 3rem);
--font-size-h3: clamp(1.5rem, 3.5vw, 2.5rem);
--font-size-body: clamp(1rem, 2vw, 1.25rem);
}
body {
background: var(--background);
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
font-size: var(--font-size-body);
}
h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }
.container-custom {
max-width: 100%;
margin-left: auto;
margin-right: auto;
padding-left: 1rem;
padding-right: 1rem;
}
@media (min-width: 1280px) {
.container-custom { max-width: 1280px; }
}
@media (min-width: 1536px) {
.container-custom { max-width: 1440px; }
}
@media (min-width: 1920px) {
.container-custom { max-width: 1920px; }
}
html {
scroll-behavior: smooth;
}
/* Responsive images */
img {
max-width: 100%;
height: auto;
}
/* Ensure images cover their container if needed */
.cover-container {
width: 100%;
height: 100%;
object-fit: cover;
}
Updated TextSection Component
const TextSection: React.FC<TextSectionProps> = ({
title,
paragraphs,
tagline,
}) => {
return (
<div className="text-section">
{title && title.trim() !== "" && <h3 className="text-section__title">{title}</h3>}
{paragraphs.map((text, index) => (
<p key={index} className="text-section__paragraph">{text}</p>
))}
{tagline && <p className="text-section__tagline">{tagline}</p>}
</div>
);
};
export default TextSection;
Updated page.tsx
return (
<main className="container-custom">
<div className="mx-auto">
<Navbar />
<section id="home" className="scroll-mt-10">
<TitlePage
title={titlePageData.title}
creators={titlePageData.creators}
motto={titlePageData.motto}
logos={titlePageData.logos}
/>
</section>
<section id="whoweare" className="scroll-mt-10">
<InfoSection
title={whoweare.title}
paragraphs={whoweare.paragraphs}
circles={whoweare.circles}
/>
</section>
{/* Add more sections as needed */}
</div>
</main>
);