मुख्य सामग्री पर जाईं डॉक्स नेविगेशन पर जाईं
Check
in English

पृष्ठभूमि

के माध्यम से अर्थ संप्रेषित करीं background-colorआ ढाल के साथ सजावट जोड़ीं।

पृष्ठभूमि के रंग के बा

संदर्भ पाठ रंग वर्ग सभ के समान, कौनों तत्व के पृष्ठभूमि के कौनों भी संदर्भ वर्ग पर सेट करीं। बैकग्राउंड यूटिलिटीज सेट नाcolor होला , एह से कुछ मामला में रउआ .text-* रंग यूटिलिटीज के इस्तेमाल करे के चाहब .

.बीजी-प्राइमरी के बा
.बीजी-माध्यमिक के बा
.बीजी-सफलता के बा
.बीजी-खतरा के बा
.बीजी-चेतावनी बा
.बीजी-इंफो के बा
.बीजी-लाइट के बा
.बीजी-अंधेरा के बा
.बीजी-शरीर के बा
.बीजी-गोरा रंग के बा
.बीजी-पारदर्शी के बा
एचटीएमएल के बा
<div class="p-3 mb-2 bg-primary text-white">.bg-primary</div>
<div class="p-3 mb-2 bg-secondary text-white">.bg-secondary</div>
<div class="p-3 mb-2 bg-success text-white">.bg-success</div>
<div class="p-3 mb-2 bg-danger text-white">.bg-danger</div>
<div class="p-3 mb-2 bg-warning text-dark">.bg-warning</div>
<div class="p-3 mb-2 bg-info text-dark">.bg-info</div>
<div class="p-3 mb-2 bg-light text-dark">.bg-light</div>
<div class="p-3 mb-2 bg-dark text-white">.bg-dark</div>
<div class="p-3 mb-2 bg-body text-dark">.bg-body</div>
<div class="p-3 mb-2 bg-white text-dark">.bg-white</div>
<div class="p-3 mb-2 bg-transparent text-dark">.bg-transparent</div>

पृष्ठभूमि के ढाल के बारे में बतावल गइल बा

क्लास जोड़ .bg-gradientके बैकग्राउंड सभ में बैकग्राउंड इमेज के रूप में रेखीय ढाल जोड़ल जाला। ई ढाल अर्ध-पारदर्शी सफेद रंग से शुरू होला जे नीचे ले फीका हो जाला।

का रउरा अपना कस्टम सीएसएस में ढाल के जरूरत बा? बस जोड़ल जाव background-image: var(--bs-gradient);.

.बीजी-प्राथमिक.बीजी-ढाल के बा
.बीजी-माध्यमिक.बीजी-ढाल के बा
.बीजी-सफलता.बीजी-ढाल के बा
.बीजी-खतरा.बीजी-ढाल के बा
.बीजी-चेतावनी.बीजी-ढाल के बा
.bg-info.bg-ढाल के बा
.बीजी-लाइट.बीजी-ढाल के बा
.बीजी-डार्क.बीजी-ढाल के बा

अस्पष्टता के बा

v5.1.0 में जोड़ल गइल बा

v5.1.0 के रूप में, background-colorउपयोगिता सभ के CSS चर सभ के इस्तेमाल से Sass के साथ जनरेट कइल जाला। एह से बिना संकलन आ डायनामिक अल्फा पारदर्शिता में बदलाव के रियल-टाइम रंग बदले के इजाजत मिले ला।

कइसे काम करेला

हमनी के डिफ़ॉल्ट .bg-successउपयोगिता पर विचार करीं।

.bg-success {
  --bs-bg-opacity: 1;
  background-color: rgba(var(--bs-success-rgb), var(--bs-bg-opacity)) !important;
}

हमनी के अपना --bs-success(के मान के साथ ) CSS चर के एगो RGB संस्करण के इस्तेमाल करेनी जा आ अल्फा पारदर्शिता खातिर 25, 135, 84एगो दूसरा CSS चर, , संलग्न कइले बानी जा (एक ठो स्थानीय CSS चर के बदौलत डिफ़ॉल्ट मान के साथ)। मतलब कि अब कबो भी रउआ इस्तेमाल करीं, रउआ गणना कइल मान . हर क्लास के अंदर के लोकल CSS चर विरासत के मुद्दा से बचेला एह से उपयोगिता सभ के नेस्टेड इंस्टेंस सभ में स्वचालित रूप से संशोधित अल्फा पारदर्शिता ना होखे।--bs-bg-opacity1.bg-successcolorrgba(25, 135, 84, 1).bg-*

उदाहरण

ओह अस्पष्टता के बदले खातिर, --bs-bg-opacityकस्टम स्टाइल भा इनलाइन स्टाइल के माध्यम से ओवरराइड करीं।

ई डिफ़ॉल्ट सफलता के पृष्ठभूमि बा
ई 50% अस्पष्टता सफलता पृष्ठभूमि ह
एचटीएमएल के बा
<div class="bg-success p-2 text-white">This is default success background</div>
<div class="bg-success p-2" style="--bs-bg-opacity: .5;">This is 50% opacity success background</div>

.bg-opacityया, कवनो उपयोगिता में से चुनीं :

ई डिफ़ॉल्ट सफलता के पृष्ठभूमि बा
ई 75% अस्पष्टता सफलता पृष्ठभूमि बा
ई 50% अस्पष्टता सफलता पृष्ठभूमि ह
ई 25% अस्पष्टता सफलता पृष्ठभूमि ह
ई 10% अस्पष्टता सफलता पृष्ठभूमि ह
एचटीएमएल के बा
<div class="bg-success p-2 text-white">This is default success background</div>
<div class="bg-success p-2 text-white bg-opacity-75">This is 75% opacity success background</div>
<div class="bg-success p-2 text-dark bg-opacity-50">This is 50% opacity success background</div>
<div class="bg-success p-2 text-dark bg-opacity-25">This is 25% opacity success background</div>
<div class="bg-success p-2 text-dark bg-opacity-10">This is 10% opacity success background</div>

ससस के बा

निम्नलिखित Sass कार्यक्षमता के अलावा, रंग आ अउरी बहुत कुछ खातिर हमनी के शामिल CSS कस्टम गुण (उर्फ CSS चर) के बारे में पढ़े पर विचार करीं।

चर के बारे में बतावल गइल बा

अधिकतर background-colorउपयोगिता हमनी के थीम रंग द्वारा जनरेट कइल जाला, हमनी के जेनेरिक रंग पैलेट चर से फिर से असाइन कइल जाला।

$blue:    #0d6efd;
$indigo:  #6610f2;
$purple:  #6f42c1;
$pink:    #d63384;
$red:     #dc3545;
$orange:  #fd7e14;
$yellow:  #ffc107;
$green:   #198754;
$teal:    #20c997;
$cyan:    #0dcaf0;
$primary:       $blue;
$secondary:     $gray-600;
$success:       $green;
$info:          $cyan;
$warning:       $yellow;
$danger:        $red;
$light:         $gray-100;
$dark:          $gray-900;
$gradient: linear-gradient(180deg, rgba($white, .15), rgba($white, 0));

ग्रेस्केल रंग भी उपलब्ध बा, बाकी कौनों भी उपयोगिता पैदा करे खातिर खाली एगो सबसेट के इस्तेमाल होला।

$white:    #fff;
$gray-100: #f8f9fa;
$gray-200: #e9ecef;
$gray-300: #dee2e6;
$gray-400: #ced4da;
$gray-500: #adb5bd;
$gray-600: #6c757d;
$gray-700: #495057;
$gray-800: #343a40;
$gray-900: #212529;
$black:    #000;

नक्शा बनावल गइल बा

एकरे बाद थीम रंग सभ के सास मैप में डाल दिहल जाला ताकि हमनी के इनहन पर लूप क के आपन यूटिलिटीज, कंपोनेंट मोडिफायर आ अउरी बहुत कुछ जनरेट क सके लीं।

$theme-colors: (
  "primary":    $primary,
  "secondary":  $secondary,
  "success":    $success,
  "info":       $info,
  "warning":    $warning,
  "danger":     $danger,
  "light":      $light,
  "dark":       $dark
);

ग्रेस्केल रंग भी सास मैप के रूप में उपलब्ध बा। एह नक्शा के इस्तेमाल कवनो उपयोगिता पैदा करे खातिर ना कइल जाला.

$grays: (
  "100": $gray-100,
  "200": $gray-200,
  "300": $gray-300,
  "400": $gray-400,
  "500": $gray-500,
  "600": $gray-600,
  "700": $gray-700,
  "800": $gray-800,
  "900": $gray-900
);

आरजीबी रंग अलग से सास मैप से जनरेट कइल जाला:

$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");

आ बैकग्राउंड रंग के अस्पष्टता सभ ओह पर आपन खुद के मैप के साथ बिल्ड करे लीं जे यूटिलिटीज एपीआई द्वारा खपत होला:

$utilities-bg: map-merge(
  $utilities-colors,
  (
    "black": to-rgb($black),
    "white": to-rgb($white),
    "body": to-rgb($body-bg)
  )
);
$utilities-bg-colors: map-loop($utilities-bg, rgba-css-var, "$key", "bg");

मिक्सिन के नाम से जानल जाला

हमनी के बैकग्राउंड उपयोगिता पैदा करे खातिर कवनो मिक्सिन के इस्तेमाल ना कइल जाला , लेकिन हमनी के लगे कुछ अतिरिक्त मिक्सिन बा अन्य स्थिति खातिर जहाँ रउआ आपन ढाल बनावल चाहत बानी।

@mixin gradient-bg($color: null) {
  background-color: $color;

  @if $enable-gradients {
    background-image: var(--#{$prefix}gradient);
  }
}
// Horizontal gradient, from left to right
//
// Creates two color stops, start and end, by specifying a color and position for each color stop.
@mixin gradient-x($start-color: $gray-700, $end-color: $gray-800, $start-percent: 0%, $end-percent: 100%) {
  background-image: linear-gradient(to right, $start-color $start-percent, $end-color $end-percent);
}

// Vertical gradient, from top to bottom
//
// Creates two color stops, start and end, by specifying a color and position for each color stop.
@mixin gradient-y($start-color: $gray-700, $end-color: $gray-800, $start-percent: null, $end-percent: null) {
  background-image: linear-gradient(to bottom, $start-color $start-percent, $end-color $end-percent);
}

@mixin gradient-directional($start-color: $gray-700, $end-color: $gray-800, $deg: 45deg) {
  background-image: linear-gradient($deg, $start-color, $end-color);
}

@mixin gradient-x-three-colors($start-color: $blue, $mid-color: $purple, $color-stop: 50%, $end-color: $red) {
  background-image: linear-gradient(to right, $start-color, $mid-color $color-stop, $end-color);
}

@mixin gradient-y-three-colors($start-color: $blue, $mid-color: $purple, $color-stop: 50%, $end-color: $red) {
  background-image: linear-gradient($start-color, $mid-color $color-stop, $end-color);
}

@mixin gradient-radial($inner-color: $gray-700, $outer-color: $gray-800) {
  background-image: radial-gradient(circle, $inner-color, $outer-color);
}

@mixin gradient-striped($color: rgba($white, .15), $angle: 45deg) {
  background-image: linear-gradient($angle, $color 25%, transparent 25%, transparent 50%, $color 50%, $color 75%, transparent 75%, transparent);
}

उपयोगिता एपीआई के बा

बैकग्राउंड यूटिलिटीज के हमनी के यूटिलिटीज एपीआई में घोषित कइल गइल बा scss/_utilities.scss. उपयोगिता एपीआई के इस्तेमाल करे के तरीका जानें।

    "background-color": (
      property: background-color,
      class: bg,
      local-vars: (
        "bg-opacity": 1
      ),
      values: map-merge(
        $utilities-bg-colors,
        (
          "transparent": transparent
        )
      )
    ),
    "bg-opacity": (
      css-var: true,
      class: bg-opacity,
      values: (
        10: .1,
        25: .25,
        50: .5,
        75: .75,
        100: 1
      )
    ),