← Back to Bootstrap Course | Chapter 9: Layout Utilities | Lesson 7 of 7

Float क्या है

Float utilities elements को left या right की ओर push करती हैं और text को इनके आर-पार wrap होने देती हैं।

In this page:

  1. Float
Syntax
markup
<div class="float-start">left</div>
<div class="float-end">right</div>
<div class="clearfix"></div>

Float

.float-start और .float-end elements float करते हैं, .float-none reset करता है, और .float-md-end जैसे breakpoint versions exist करते हैं। Floated elements normal flow छोड़ देते हैं, इसलिए parent पर .clearfix से इन्हें clear करें।

Modern layouts के लिए floats से flexbox या grid prefer करें।

Note: floated children के container में clearfix add करें ताकि यह इन्हें wrap करे।

उदाहरण: Float

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="clearfix border p-2">
    <div class="float-start bg-info-subtle p-2 me-2">float-start</div>
    <div class="float-end bg-warning-subtle p-2 ms-2">float-end</div>
    <p>Text wraps between the floated boxes and the clearfix parent contains them all.</p>
  </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. clearfix भूल जाना
  2. पूरे-page layouts के लिए floats इस्तेमाल करना
  3. Bootstrap 4 से float-left इस्तेमाल करना
चैप्टर सारांश
  • float-start और float-end
  • float-none reset करता है
  • Breakpoint versions exist करते हैं
  • Parent पर clearfix इस्तेमाल करें
🔒

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.