← Back to Bootstrap Course | Chapter 2: Grid System | Lesson 1 of 7

Grid के Basics

Grid एक container, rows, और columns से बनता है जो content को rows में line up करते हैं।

In this page:

  1. Grid Basics
Syntax
markup
<div class="container">
  <div class="row">
    <div class="col">column</div>
    <div class="col">column</div>
  </div>
</div>

Grid Basics

एक container के अंदर एक .row रखें और row के अंदर .col elements। Rows flexbox और negative margins इस्तेमाल करते हैं column gutters offset करने के लिए, और columns padding carry करते हैं। Content हमेशा columns के अंदर रहना चाहिए।

Note: कभी content सीधे एक row में न रखें; इसे एक col में wrap करें।

उदाहरण: Grid basics

markup
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container">
  <div class="row">
    <div class="col bg-primary-subtle border p-2">One</div>
    <div class="col bg-success-subtle border p-2">Two</div>
    <div class="col bg-warning-subtle border p-2">Three</div>
  </div>
</div>
</body>
</html>
Live Example
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. columns को एक row के बाहर रखना
  2. content सीधे rows में रखना
  3. container भूल जाना
चैप्टर सारांश
  • container > row > col structure इस्तेमाल होता है
  • Rows flex containers हैं
  • Columns content और gutters hold करते हैं
  • Content columns के अंदर जाता है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.