जानिए CSS Multi-Column Layout की मदद से बिना Flexbox या Grid के किसी भी webpage के text को newspaper या magazine जैसे attractive columns में कैसे divide किया जाता है। Full-stack developers के लिए एक complete practical guide।
CSS Multi-Column Layout क्या है? Newspaper जैसा Responsive Layout बनाना सीखें
जब भी हम किसी website पर article, blog या news पढ़ते हैं, तो कई बार लंबा text एक ही चौड़े paragraph में पढ़ने में boring और मुश्किल लगता है। यही वजह है कि newspapers और magazines में content को छोटे-छोटे columns में बांटा जाता है। Web development में यही काम करने के लिए CSS Multi-Column Layout का इस्तेमाल किया जाता है।
अक्सर developers layout बनाने के लिए Flexbox या CSS Grid का उपयोग करते हैं, लेकिन जब बात सिर्फ लंबे text और content flow को columns में divide करने की आती है, तो Multi-Column Layout सबसे बेहतरीन और आसान विकल्प है। Vivaa Technologies के इस tutorial में हम इस powerful CSS feature को विस्तार से समझेंगे।
CSS Multi-Column Layout क्या है?
CSS Multi-Column Layout एक ऐसा module है जो आपको किसी भी HTML container के अंदर मौजूद content (जैसे paragraphs, headings या images) को एक से ज्यादा columns में व्यवस्थित करने की सुविधा देता है। इसकी सबसे खास बात यह है कि content एक column के भरने के बाद अपने आप अगले column में flow हो जाता है, ठीक किसी printed magazine की तरह।
Multi-Column Layout की मुख्य CSS Properties
इसे लागू करना बेहद आसान है। आइए इसकी सबसे महत्वपूर्ण properties को example के साथ समझते हैं:
1. column-count
यह property तय करती है कि आपके content को कितने बराबर columns में बांटा जाएगा।
CSS
.article-container {
column-count: 3;
}
ऊपर दिए गए code से container का पूरा content 3 बराबर हिस्सों में बंट जाएगा।
2. column-width
अगर आप columns की संख्या fix करने के बजाय हर column की एक minimum width तय करना चाहते हैं, तो column-width का उपयोग करें। यह property layout को अपने आप responsive बना देती है।
CSS
.article-container {
column-width: 250px;
}
Browser screen के size के हिसाब से उतने ही columns बनाएगा जिनकी width कम से कम 250px हो सके।
3. column-gap
दो columns के बीच खाली जगह (spacing) देने के लिए column-gap का इस्तेमाल किया जाता है।
CSS
.article-container {
column-count: 3;
column-gap: 40px;
}
4. column-rule
अगर आप दो columns के बीच में एक vertical line (border) दिखाना चाहते हैं, तो column-rule का उपयोग करें। यह बिल्कुल border property की तरह काम करता है।
CSS
.article-container {
column-count: 3;
column-gap: 40px;
column-rule: 2px solid #e0e0e0;
}
5. column-span
कई बार हमें columns के बीच में एक ऐसी heading चाहिए होती है जो सभी columns के ऊपर पूरी width में दिखे। इसके लिए column-span: all; का उपयोग किया जाता है।
CSS
.article-heading {
column-span: all;
text-align: center;
margin-bottom: 20px;
}
6. break-inside
Columns में content बंटते समय कई बार कोई card, image या paragraph बीच से कटकर आधा एक column में और आधा दूसरे column में चला जाता है। इसे रोकने के लिए break-inside: avoid; का इस्तेमाल किया जाता है।
CSS
.card-item {
break-inside: avoid;
}
एक Complete Practical Example
आइए इन सभी properties को मिलाकर एक clean और professional layout तैयार करते हैं:
HTML
<div class="newspaper-layout">
<h2 class="main-heading">Modern Web Development Trends</h2>
<p>
Web development की दुनिया बहुत तेजी से बदल रही है। आज के समय में user experience (UX)
और readability किसी भी website की सफलता के लिए सबसे महत्वपूर्ण हैं...
</p>
<p>
CSS के modern features जैसे Grid, Flexbox और Multi-Column Layout developers को बिना
ज्यादा JavaScript लिखे शानदार responsive design बनाने की ताकत देते हैं...
</p>
</div>
CSS
.newspaper-layout {
columns: 250px 3; /* Shorthand for column-width and column-count */
column-gap: 35px;
column-rule: 1px dashed #cccccc;
padding: 20px;
line-height: 1.6;
}
.main-heading {
column-span: all;
font-size: 24px;
margin-bottom: 15px;
}
Multi-Column Layout का उपयोग कब करें?
लंबे blog posts और articles: Text की readability बढ़ाने के लिए।
List items और navigation menu: लंबी category list को कम जगह में दिखाने के लिए।
Pinterest जैसा Masonry Layout: Images और cards को बिना किसी extra library के व्यवस्थित करने के लिए।
निष्कर्ष
CSS Multi-Column Layout एक underrated लेकिन बेहद उपयोगी tool है जो आपके front-end development workflow को काफी तेज और clean बना सकता है। बिना media queries लिखे responsive text layout बनाने के लिए यह सबसे best तरीका है।
अगर आप full-stack web development को basic से advanced level तक practical projects के साथ सीखना चाहते हैं, तो आज ही Vivaa Technologies के courses और resources को explore करें और अपनी coding journey को अगले स्तर पर ले जाएं।



