CSS Frameworks Overview
In this page:
CSS Frameworks क्या हैं?
CSS Frameworks CSS classes, grids, और components की pre-written libraries हैं जो development times तेज़ करने और आपके project में consistent styling establish करने के लिए design की गई हैं।
उदाहरण: What are CSS Frameworks?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<style>
.container { background: #e7f1ff; border: 2px solid #0d6efd; padding: 1rem; }
</style>
</head>
<body>
<div class="container">Pre-written classes, grids, and components</div>
</body>
</html>
Utility-First Architecture
Utility-first frameworks (जैसे Tailwind CSS) छोटी, single-purpose classes की libraries provide करते हैं (जैसे padding के लिए p-4 या centering के लिए text-center) जो आपको सीधे अपने HTML markup के अंदर elements style करने देती हैं।
उदाहरण: Utility-First Architecture
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="https://cdn.tailwindcss.com"></script>
<style>
body { font-family: sans-serif; }
</style>
</head>
<body>
<div class="p-4 text-center bg-blue-100 border-2 border-blue-500">Tiny single-purpose classes</div>
</body>
</html>
Component-Driven Architecture
Component-driven frameworks (जैसे Bootstrap या Bulma) पूरे UI components (जैसे navigation bars, cards, modals, या forms) के लिए pre-written classes provide करते हैं, आपको कुछ ही minutes में standard pages बनाने देते हुए।
उदाहरण: Component-Driven Architecture
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<style>
body { padding: 1rem; }
</style>
</head>
<body>
<nav class="navbar navbar-light bg-light border">Pre-written navbar component</nav>
</body>
</html>
Default Theme Configurations Customize करना
अपनी website को दूसरों जैसी identical दिखने से रोकने के लिए, ज़्यादातर frameworks आपको design variables इस्तेमाल करके उनकी default theme configurations (जैसे colors, fonts, या breakpoints) customize करने देते हैं।
उदाहरण: Customizing Default Theme Configurations
<style>
:root {
--bs-primary: #ff5733;
}
</style>
<button class="btn btn-primary">Themed button</button>
Unused CSS को Optimize और Purge करना
क्योंकि CSS frameworks हज़ारों classes की libraries provide करते हैं, उनकी file sizes बहुत बड़ी हो सकती हैं। अपनी website को तेज़ और optimized रखने के लिए, आपको publish करने से पहले अपने HTML को scan करने और किसी भी unused classes को automatically strip out करने के लिए optimization tools (जैसे PurgeCSS) इस्तेमाल करने चाहिए।
उदाहरण: Optimizing and Purging Unused CSS
<style>
.btn { background: royalblue; color: white; padding: 10px 20px; border: 0; }
/* .legacy-banner { ... } is never used in the HTML: PurgeCSS would strip it */
/* PurgeCSS scans your HTML and strips out any unused classes
from the compiled framework CSS before you publish */
</style>
<button class="btn">Used class kept</button>
- CSS frameworks को उनके colors और layouts customize किए बिना इस्तेमाल करना, आपकी site को generic दिखाते हुए।
- अपनी final files से unused classes purge करने में fail होना, bloated stylesheets के साथ page load times धीमी करते हुए।
- पर्याप्त specific CSS selectors इस्तेमाल किए बिना framework component classes को override करने की कोशिश करना।
- CSS Frameworks development times तेज़ करने के लिए style classes, grids, और UI components की pre-written libraries provide करते हैं।
- custom designs के लिए utility-first frameworks (जैसे Tailwind), और तेज़, standard layouts के लिए component-driven (जैसे Bootstrap) चुनें।
- अपनी brand identity से match करने के लिए theme variables customize करें, और अपनी stylesheets को lightweight और तेज़ रखने के लिए publish करने से पहले unused classes purge करें।
Compiled framework stylesheets हर modern web browser द्वारा natively supported हैं।
Chapter Quiz — Complete all 25 topics to unlock
0/25 topics done
Complete these topics first:
- CSS Container Queries
- CSS Subgrid
- CSS Logical Properties
- CSS Logical Sizing
- CSS Writing Modes
- CSS Aspect Ratio
- CSS Object Fit
- CSS object-position
- CSS Masking
- CSS Math Functions
- CSS Motion Path
- CSS @supports
- CSS @property
- CSS At-Rules
- CSS Cursor
- CSS Will Change
- CSS User Interface
- CSS Print Styles
- CSS Pagination (Print)
- CSS Dark Mode
- CSS Accessibility
- CSS Performance
- CSS Preprocessors
- CSS Frameworks Overview
- CSS Interview Prep