← Back to Bootstrap Course | Chapter 10: Responsive Design | Lesson 2 of 7

Responsive Embeds बनाना

Ratio helpers videos और iframes को width बदलने पर सही shape में रखते हैं।

In this page:

  1. Responsive Embeds
Syntax
markup
<div class="ratio ratio-16x9">
  <iframe src="url" allowfullscreen></iframe>
</div>

Responsive Embeds

एक iframe, video, या embed को .ratio-16x9, .ratio-4x3, .ratio-1x1, या .ratio-21x9 जैसी एक ratio class के साथ .ratio में wrap करें। Child automatically box भर देता है। Custom ratios --bs-aspect-ratio CSS variable इस्तेमाल करते हैं।

Note: ratio-16x9 standard widescreen video shape है।

उदाहरण: Responsive embeds

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" style="max-width: 32rem">
  <div class="ratio ratio-16x9 bg-dark text-white d-flex align-items-center justify-content-center">
    <div class="d-flex align-items-center justify-content-center">16:9 embed area (iframe or video goes here)</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. old embed-responsive classes इस्तेमाल करना
  2. Fixed iframe width और height
  3. ratio wrapper भूल जाना
चैप्टर सारांश
  • .ratio embeds wrap करता है
  • ratio-16x9, 4x3, 1x1, 21x9 jaise ratios मिलते हैं
  • Child box भर देता है
  • Custom ratios एक CSS variable इस्तेमाल करते हैं
🔒

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.