Rekọja si akoonu akọkọ Rekọja si lilọ kiri awọn docs
Check
in English

Àwọ̀

Bootstrap jẹ atilẹyin nipasẹ eto awọ lọpọlọpọ ti o ṣe akori awọn aza ati awọn paati wa. Eyi jẹ ki isọdi pipe diẹ sii ati itẹsiwaju fun eyikeyi iṣẹ akanṣe.

Awọn awọ akori

A lo ipin kan ti gbogbo awọn awọ lati ṣẹda paleti awọ ti o kere fun ṣiṣẹda awọn ero awọ, tun wa bi awọn oniyipada Sass ati maapu Sass kan ninu scss/_variables.scssfaili Bootstrap.

Alakoko
Atẹle
Aseyori
Ijamba
Ikilo
Alaye
Imọlẹ
Dudu

Gbogbo awọn awọ wọnyi wa bi maapu Sass, $theme-colors.

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

Ṣayẹwo awọn maapu Sass wa ati awọn docs loops fun bi o ṣe le yipada awọn awọ wọnyi.

Gbogbo awọn awọ

Gbogbo awọn awọ Bootstrap wa bi awọn oniyipada Sass ati maapu Sass kan ninu scss/_variables.scssfaili. Lati yago fun awọn iwọn faili ti o pọ si, a ko ṣẹda ọrọ tabi awọn kilasi awọ abẹlẹ fun ọkọọkan awọn oniyipada wọnyi. Dipo, a yan ipin kan ti awọn awọ wọnyi fun paleti akori kan .

Rii daju lati ṣe atẹle awọn ipin itansan bi o ṣe n ṣatunṣe awọn awọ. Gẹgẹbi a ti han ni isalẹ, a ti ṣafikun awọn ipin itansan mẹta si ọkọọkan awọn awọ akọkọ-ọkan fun awọn awọ lọwọlọwọ swatch, ọkan lodi si funfun, ati ọkan fun lodi si dudu.

$bulu#0d6efd
bulu-100
bulu-200
bulu-300
bulu-400
bulu-500
bulu-600
bulu-700
bulu-800
bulu-900
$indigo# 6610f2
$indigo-100
$indigo-200
$indigo-300
$indigo-400
$indigo-500
$indigo-600
$ indigo-700
$ indigo-800
$indigo-900
$ eleyi ti# 6f42c1
$ eleyi ti-100
$ eleyi ti-200
$ eleyi ti-300
$ eleyi ti-400
$ eleyi ti-500
$ eleyi ti-600
$ eleyi ti-700
$ eleyi ti-800
$ eleyi ti-900
$ Pink#d63384
$ Pink-100
$ Pink-200
$ Pink-300
$ Pink-400
$ Pink-500
$ Pink-600
$ Pink-700
$ Pink-800
$ Pink-900
$pupa#dc3545
$ pupa-100
$ pupa-200
$ pupa-300
$ pupa-400
$ pupa-500
$ pupa-600
$ pupa-700
$ pupa-800
$ pupa-900
$ọsan#fd7e14
$ osan-100
$ osan-200
$ osan-300
$ osan-400
$ osan-500
$ osan-600
$ osan-700
$ osan-800
$ osan-900
$ ofeefee#ffc107
$ ofeefee-100
$ ofeefee-200
$ ofeefee-300
$ ofeefee-400
$ ofeefee-500
$ ofeefee-600
$ ofeefee-700
$ ofeefee-800
$ ofeefee-900
$ alawọ ewe#198754
$ alawọ-100
$ alawọ-200
$ alawọ-300
$ alawọ-400
$ alawọ-500
$ alawọ-600
alawọ ewe-700
$ alawọ-800
$ alawọ-900
$teli#20c997
$ teli-100
$ 200
$ teli-300
$ teli-400
$ teli-500
$ teli-600
$ teli-700
$ teli-800
$ teli-900
$ cyan#0dcaf0
$ cyan-100
$ cyan-200
$ cyan-300
$ cyan-400
$ cyan-500
$ cyan-600
$ cyan-700
$ cyan-800
$ cyan-900
$ grẹy-500#adb5bd
$ grẹy-100
$ grẹy-200
$ grẹy-300
$ grẹy-400
$ grẹy-500
$ grẹy-600
$ grẹy-700
$ grẹy-800
$ grẹy-900
$dudu#000
$funfun#ffff

Awọn akọsilẹ lori Sass

Sass ko le ṣe ipilẹṣẹ awọn oniyipada ni eto, nitorinaa a ṣẹda awọn oniyipada pẹlu ọwọ fun gbogbo tint ati iboji ara wa. A pato iye midpoint (fun apẹẹrẹ, $blue-500) ati lo awọn iṣẹ awọ aṣa lati tint (imọlẹ) tabi iboji (ṣokunkun) awọn awọ wa nipasẹ iṣẹ mix()awọ Sass.

Lilo mix()kii ṣe kanna bii lighten()ati darken()- iṣaju ṣe idapọ awọ ti a sọ pato pẹlu funfun tabi dudu, lakoko ti igbehin nikan n ṣatunṣe iye ina ti awọ kọọkan. Abajade jẹ suite awọn awọ pipe diẹ sii, bi a ṣe han ninu demo CodePen yii .

Wa tint-color()ati shade-color()awọn iṣẹ lo mix()lẹgbẹẹ $theme-color-intervaloniyipada wa, eyiti o ṣalaye iye ipin ogorun kan fun awọ idapọmọra kọọkan ti a ṣe. Wo scss/_functions.scssati scss/_variables.scssawọn faili fun koodu orisun ni kikun.

Awọn maapu Sass awọ

Awọn faili Sass orisun Bootstrap pẹlu awọn maapu mẹta lati ṣe iranlọwọ fun ọ ni iyara ati irọrun lupu lori atokọ ti awọn awọ ati awọn iye hex wọn.

  • $colorsṣe atokọ gbogbo awọn awọ ipilẹ ti o wa ( 500).
  • $theme-colorsṣe atokọ gbogbo awọn awọ akori ti a darukọ ni itumọ-ọrọ (ti o han ni isalẹ)
  • $graysṣe akojọ gbogbo awọn tints ati awọn ojiji ti grẹy

Ninu scss/_variables.scss, iwọ yoo rii awọn oniyipada awọ Bootstrap ati maapu Sass. Eyi ni apẹẹrẹ ti $colorsmaapu Sass:

$colors: (
  "blue":       $blue,
  "indigo":     $indigo,
  "purple":     $purple,
  "pink":       $pink,
  "red":        $red,
  "orange":     $orange,
  "yellow":     $yellow,
  "green":      $green,
  "teal":       $teal,
  "cyan":       $cyan,
  "black":      $black,
  "white":      $white,
  "gray":       $gray-600,
  "gray-dark":  $gray-800
);

Ṣafikun, yọkuro, tabi ṣatunṣe awọn iye laarin maapu lati ṣe imudojuiwọn bi wọn ṣe nlo ni ọpọlọpọ awọn paati miiran. Laanu ni akoko yii, kii ṣe gbogbo paati lo maapu Sass yii. Awọn imudojuiwọn ọjọ iwaju yoo tiraka lati ni ilọsiwaju lori eyi. Titi di igba naa, gbero lori lilo awọn ${color}oniyipada ati maapu Sass yii.

Apeere

Eyi ni bii o ṣe le lo awọn wọnyi ninu Sass rẹ:

.alpha { color: $purple; }
.beta {
  color: $yellow-300;
  background-color: $indigo-900;
}

Awọ ati awọn kilasi IwUlO lẹhin tun wa fun eto colorati background-colorlilo awọn 500iye awọ.

Ṣiṣe awọn ohun elo

Fi kun v5.1.0

Bootstrap ko pẹlu colorati background-colorawọn ohun elo fun gbogbo oniyipada awọ, ṣugbọn o le ṣe ina wọnyi funrararẹ pẹlu API IwUlO wa ati awọn maapu Sass ti o gbooro sii ti a ṣafikun ni v5.1.0.

  1. Lati bẹrẹ, rii daju pe o ti gbe wọle awọn iṣẹ wa, awọn oniyipada, awọn apopọ, ati awọn ohun elo.
  2. Lo map-merge-multiple()iṣẹ wa lati yara dapọ ọpọlọpọ awọn maapu Sass papọ ni maapu tuntun kan.
  3. Darapọ mọ maapu apapọ tuntun yii lati faagun eyikeyi ohun elo pẹlu {color}-{level}orukọ kilasi kan.

Eyi ni apẹẹrẹ ti o ṣe agbejade awọn ohun elo awọ ọrọ (fun apẹẹrẹ, .text-purple-500) ni lilo awọn igbesẹ loke.

@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";

$all-colors: map-merge-multiple($blues, $indigos, $purples, $pinks, $reds, $oranges, $yellows, $greens, $teals, $cyans);

$utilities: map-merge(
  $utilities,
  (
    "color": map-merge(
      map-get($utilities, "color"),
      (
        values: map-merge(
          map-get(map-get($utilities, "color"), "values"),
          (
            $all-colors
          ),
        ),
      ),
    ),
  )
);

@import "bootstrap/scss/utilities/api";

Eyi yoo ṣe ina awọn .text-{color}-{level}ohun elo tuntun fun gbogbo awọ ati ipele. O le ṣe kanna fun eyikeyi ohun elo miiran ati ohun-ini daradara.