Modular CSS

Modulares CSS mit PHP

What is Modular CSS?

How is the system structured?

CSS File Structure

CSS file structure:
config.css.php - Contains all variables and configuration settings
base.css.php - Basic styles for HTML elements
main.css.php - Collects all styles and generates the final CSS
components/* - Reusable UI components
layout/* - Layout-specific styles
pages/* - Page-specific styles

Combining all modules in main CSS

$cssModules = [
['base', 'comment', 'Basic styles for the page'],
['base', 'styles', renderBodyStyle()],
['h2', 'comment', 'Heading level 2 styles'],
['h2', 'styles', renderH2Style()]
];

How does the CSS look in code?

function renderH2Style() {
return [
'h2' => [
'margin-top' => '30px'
]
];
}

What else is important?

Advantages of modules
Tips for usage