← Back to Bootstrap Course | Chapter 4: Colors & Spacing | Lesson 7 of 7

Opacity क्या है

Opacity utilities एक element को कम या ज़्यादा see-through बनाती हैं।

In this page:

  1. Opacity
Syntax
markup
<div class="opacity-50">content</div>

Opacity

.opacity-100, .opacity-75, .opacity-50, और .opacity-25 पूरे element की transparency set करते हैं। सिर्फ colours के लिए, .text-opacity-* और .bg-opacity-* इस्तेमाल करें, जो content को पूरी तरह opaque छोड़ते हैं। Opacity children को भी affect करता है, इसलिए सही utility चुनें।

Note: bg-opacity सिर्फ background बदलता है, ऊपर text नहीं।

उदाहरण: Opacity

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="bg-primary text-white p-2 mb-1 opacity-100">opacity-100</div>
  <div class="bg-primary text-white p-2 mb-1 opacity-50">opacity-50 (text fades too)</div>
  <div class="bg-primary bg-opacity-25 p-2 mb-1">bg-opacity-25 (text stays solid)</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. जब सिर्फ background fade होना चाहिए opacity इस्तेमाल करना
  2. text unreadable बनाना
  3. यह भूल जाना कि bg-opacity को एक bg colour class चाहिए
चैप्टर सारांश
  • opacity-25, 50, 75, 100 classes मिलती हैं
  • bg-opacity और text-opacity सिर्फ colours affect करते हैं
  • Opacity children को affect करता है
  • bg-opacity के लिए एक background class चाहिए
🔒

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.