Yeqela kokuqukethwe okuyinhloko Yeqela ku-docs navigation
Check
in English

Imibala

Dlulisa incazelo colorngedlanzana lamakilasi okusetshenziswa kombala. Kufaka phakathi usekelo lwezixhumanisi zesitayela ezinezifunda ze-hover, futhi.

Imibala

Faka umbala umbhalo ngezinsiza ezinemibala. Uma ufuna ukufaka imibala kuzixhumanisi, ungasebenzisa .link-*amakilasi omsizi anayo :hoverkanye :focusnezifunda.

.umbhalo-oyinhloko

.imibhalo-yesibili

.impumelelo yombhalo

.ingozi yombhalo

.isixwayiso sombhalo

.ulwazi lombhalo

.ukukhanya kombhalo

.umbhalo-mnyama

.umzimba-wombhalo

.umbhalo-uthulisiwe

.umbhalo-mhlophe

.umbhalo-omnyama-50

.umbhalo-omhlophe-50

html
<p class="text-primary">.text-primary</p>
<p class="text-secondary">.text-secondary</p>
<p class="text-success">.text-success</p>
<p class="text-danger">.text-danger</p>
<p class="text-warning bg-dark">.text-warning</p>
<p class="text-info bg-dark">.text-info</p>
<p class="text-light bg-dark">.text-light</p>
<p class="text-dark">.text-dark</p>
<p class="text-body">.text-body</p>
<p class="text-muted">.text-muted</p>
<p class="text-white bg-dark">.text-white</p>
<p class="text-black-50">.text-black-50</p>
<p class="text-white-50 bg-dark">.text-white-50</p>
Ukuhoxiswa: Ngokungezwa .text-opacity-*kwezinsiza neziguquko ze-CSS zezinsiza zombhalo, .text-black-50futhi .text-white-50ziyehliswa kusukela ku-v5.1.0. Zizosuswa ku-v6.0.0.
Ukudlulisa incazelo kubuchwepheshe obusizayo

Ukusebenzisa umbala ukwengeza incazelo kunikeza kuphela inkomba ebonakalayo, engeke idluliselwe kubasebenzisi bobuchwepheshe obusizayo - njengezifundi zesikrini. Qinisekisa ukuthi ulwazi olushiwo umbala lusobala kokuqukethwe ngokwako (isb umbhalo obonakalayo), noma lufakwe ngezinye izindlela, njengombhalo owengeziwe ofihliwe .visually-hiddennekilasi.

Ukungaboni kahle

Kwengezwe ku-v5.1.0

Kusukela ku-v5.1.0, izinsiza zombala wombhalo zenziwa nge-Sass kusetshenziswa okuguquguqukayo kwe-CSS. Lokhu kuvumela izinguquko zombala ngesikhathi sangempela ngaphandle kokuhlanganiswa nezinguquko eziguqukayo zokubonisa ngale kwe-alpha.

Isebenza kanjani

Cabangela .text-primaryinsiza yethu ezenzakalelayo.

.text-primary {
  --bs-text-opacity: 1;
  color: rgba(var(--bs-primary-rgb), var(--bs-text-opacity)) !important;
}

Sisebenzisa inguqulo ye-RGB yethu --bs-primary(ngenani 13, 110, 253) okuguquguqukayo kwe-CSS futhi sinamathisele okuguquguqukayo kwesibili kwe-CSS, --bs-text-opacity, ukuze kubonakale ngale kwe-alpha (ngenani elizenzakalelayo libonga 1ukwahluka kwendawo kwe-CSS). Lokho kusho ukuthi noma nini uma usebenzisa .text-primarymanje, inani lakho elibaliwe colorlingu- rgba(13, 110, 253, 1). Ukushintshashintsha kwendawo ye-CSS ngaphakathi .text-*kwekilasi ngalinye kugwema izinkinga zefa ukuze izimo ezibekwe esidlekeni zezinsiza zingabi nakho ukubonakala kwe-alpha okushintshiwe.

Isibonelo

Ukuze ushintshe lokho kufifi, bhala ngaphezulu --bs-text-opacityusebenzisa izitayela zangokwezifiso noma izitayela ezisemgqeni.

Lona umbhalo oyinhloko ozenzakalelayo
Lona umbhalo oyinhloko wokungafihli okungu-50%.
html
<div class="text-primary">This is default primary text</div>
<div class="text-primary" style="--bs-text-opacity: .5;">This is 50% opacity primary text</div>

Noma, khetha kunoma yiziphi .text-opacityizinsiza:

Lona umbhalo oyinhloko ozenzakalelayo
Lona umbhalo oyinhloko wokungafihli okungu-75%.
Lona umbhalo oyinhloko wokungafihli okungu-50%.
Lona umbhalo oyinhloko wokufiphala okungu-25%.
html
<div class="text-primary">This is default primary text</div>
<div class="text-primary text-opacity-75">This is 75% opacity primary text</div>
<div class="text-primary text-opacity-50">This is 50% opacity primary text</div>
<div class="text-primary text-opacity-25">This is 25% opacity primary text</div>

Ukucaciswa

Kwesinye isikhathi amakilasi omongo awakwazi ukusetshenziswa ngenxa yokucaciswa kwesinye isikhethi. Kwezinye izimo, indlela eyanele yokwenza umsebenzi iwukusonga okuqukethwe kwe- <div>elementi yakho kusici semantic noma ngaphezulu ngesigaba osifunayo.

Sass

Ngokungeziwe ekusebenzeni okulandelayo kwe-Sass, cabanga ukufunda mayelana nezakhiwo zethu zangokwezifiso ze-CSS ezifakiwe (okuguquguqukayo okuyi-CSS) ukuze uthole imibala nokunye.

Okuguquguqukayo

Izinsiza eziningi colorzenziwa imibala yetimu yethu, yabelwa kabusha isuka kokuhluka kwephalethi yethu yombala ojwayelekile.

$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;

Imibala engwevu nayo iyatholakala, kodwa isethi encane kuphela esetshenziselwa ukukhiqiza noma yiziphi izinsiza.

$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;

Imephu

Imibala yetimu ibe isifakwa kumephu ye-Sass ukuze sikwazi ukuyizungeza ukuze sikhiqize izinsiza zethu, izilungisi zezingxenye, nokunye okwengeziwe.

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

Imibala empunga iyatholakala futhi njengemephu ye-Sass. Le mephu ayisetshenziselwa ukukhiqiza noma yiziphi izinsiza.

$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
);

Imibala ye-RGB ikhiqizwa kumephu ye-Sass ehlukile:

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

Futhi ukukhanya kombala kwakhela kulokho ngemephu yawo esetshenziswa izinsiza ze-API:

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

I-Utilities API

Izinsiza zombala zivezwa kuzinsiza zethu ze-API ku- scss/_utilities.scss. Funda indlela yokusebenzisa i-API yezinsiza.

    "color": (
      property: color,
      class: text,
      local-vars: (
        "text-opacity": 1
      ),
      values: map-merge(
        $utilities-text-colors,
        (
          "muted": $text-muted,
          "black-50": rgba($black, .5), // deprecated
          "white-50": rgba($white, .5), // deprecated
          "reset": inherit,
        )
      )
    ),
    "text-opacity": (
      css-var: true,
      class: text-opacity,
      values: (
        25: .25,
        50: .5,
        75: .75,
        100: 1
      )
    ),