背景(Background)

      通過背景色傳達意義,并添加漸變裝飾。

      背景色

      與上下文文本顏色類類似,將元素的背景設置為任何上下文類。背景實用程序不設置顏色,因此在某些情況下您需要使用.text-*顏色實用程序。

      .bg-primary
      .bg-secondary
      .bg-success
      .bg-danger
      .bg-warning
      .bg-info
      .bg-light
      .bg-dark
      .bg-body
      .bg-white
      .bg-transparent
      <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梯度類,將一個線性梯度作為背景圖像添加到背景中。這個漸變從一個半透明的白色開始,逐漸消失到底部。

      你的自定義CSS需要漸變嗎?只需添加背景圖像background-image: var(--bs-gradient);。

      .bg-primary.bg-gradient
      .bg-secondary.bg-gradient
      .bg-success.bg-gradient
      .bg-danger.bg-gradient
      .bg-warning.bg-gradient
      .bg-info.bg-gradient
      .bg-light.bg-gradient
      .bg-dark.bg-gradient

      Sass

      除了下面的Sass功能外,請考慮閱讀我們的CSS自定義屬性(aka CSS variables)中包含的顏色等內容。

      Variables

      大多數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;
      

      Map

      然后將主題顏色放入Sass映射中,這樣我們就可以循環使用它們來生成實用程序、組件修改器等等。

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

      灰度顏色也可用作Sass地圖。 此映射不用于生成任何實用程序。

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

      Mixins

      沒有使用mixin來生成我們的后臺實用程序,但是我們有一些額外的mixin,用于您希望創建自己的漸變的其他情況。

      @mixin gradient-bg($color: null) {
      background-color: $color;
      
      @if $enable-gradients {
      background-image: var(--#{$variable-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);
      }
      

      Utilities API

      后臺實用程序在scss的實用程序API中聲明scss/_utilities.scss, href="http://www.roadlinkinfra.com/doc/read/162.html#using-the-api">了解如何使用實用程序API。

          "background-color": (
      property: background-color,
      class: bg,
      values: map-merge(
        $theme-colors,
        (
          "body": $body-bg,
          "white": $white,
          "transparent": transparent
        )
      )
      ),
      
      返回頂部
      主站蜘蛛池模板: 波多野结衣久久一区二区| 乱精品一区字幕二区| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 亚洲狠狠久久综合一区77777| 四虎在线观看一区二区| 国产AV一区二区三区无码野战| 国产凸凹视频一区二区| 国产日本一区二区三区| 国产在线精品一区二区不卡麻豆 | 国产在线一区二区| 亚洲无码一区二区三区| 久久精品一区二区三区AV| 国产亚洲一区二区三区在线观看| 日韩一区二区三区视频久久| 九九无码人妻一区二区三区 | 中文字幕一区二区免费| 一区二区三区四区视频在线| 日韩免费无码一区二区视频| 国精产品一区一区三区MBA下载| 亚洲一区中文字幕| 一区二区三区无码被窝影院| 久久伊人精品一区二区三区| 中文字幕一区二区三区久久网站 | 国产一区二区三区不卡在线观看 | 国产精品一区二区电影| 亚洲国产欧美日韩精品一区二区三区| 精品国产乱子伦一区二区三区 | 精品国产一区二区三区香蕉事| 精品亚洲av无码一区二区柚蜜| 久久一区二区三区精华液使用方法 | 色多多免费视频观看区一区| 国产精品一区二区在线观看| 福利一区福利二区| 国产在线不卡一区二区三区| 无码毛片视频一区二区本码 | 亚洲AV综合色一区二区三区 | 国产精品一区三区| 中文字幕一精品亚洲无线一区| 国产在线一区二区三区| 亚洲第一区二区快射影院| 亚洲国产欧美国产综合一区 |