Bootstrap4 顏色設(shè)置

2018-05-28 10:24 更新

Bootstrap4 提供了一些有代表意義的顏色類,如:.text-muted, .text-primary, .text-success, .text-info, .text-warning, .text-danger, .text-secondary, .text-white, .text-dark and .text-light:不同顏色類所代表的意義都是不同的。

實(shí)例

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap 實(shí)例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank" >
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
  <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
  <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
</head>
<body>
<div class="container">
  <h2>代表指定意義的文本顏色</h2>
  <p class="text-muted">柔和的文本。</p>
  <p class="text-primary">重要的文本。</p>
  <p class="text-success">執(zhí)行成功的文本。</p>
  <p class="text-info">代表一些提示信息的文本。</p>
  <p class="text-warning">警告文本。</p>
  <p class="text-danger">危險(xiǎn)操作文本。</p>
  <p class="text-secondary">副標(biāo)題。</p>
  <p class="text-dark">深灰色文字。</p>
  <p class="text-light">淺灰色文本(白色背景上看不清楚)。</p>
  <p class="text-white">白色文本(白色背景上看不清楚)。</p>
</div>
</body>
</html>


這些顏色類,在鏈接中也是可以使用的。

實(shí)例

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap 實(shí)例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank" >
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
  <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
  <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
</head>
<body>
<div class="container">
  <h2>文本顏色</h2>
  <p>鼠標(biāo)移動(dòng)到鏈接。</p>
  <a href="#" class="text-muted">柔和的鏈接。</a>
  <a href="#" class="text-primary">主要鏈接。</a>
  <a href="#" class="text-success">成功鏈接。</a>
  <a href="#" class="text-info">信息文本鏈接。</a>
  <a href="#" class="text-warning">警告鏈接。</a>
  <a href="#" class="text-danger">危險(xiǎn)鏈接。</a>
  <a href="#" class="text-secondary">副標(biāo)題鏈接。</a>
  <a href="#" class="text-dark">深灰色鏈接。</a>
  <a href="#" class="text-light">淺灰色鏈接。</a>
</div>
</body>
</html>


背景顏色

提供背景顏色的類有: .bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark 和 .bg-light。

注意背景顏色不會(huì)設(shè)置文本的顏色,在一些實(shí)例中你需要與 .text-* 類一起使用。

實(shí)例:

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap 實(shí)例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank" >
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
  <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
  <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
</head>
<body>
<div class="container">
  <h2>背景顏色</h2>
  <p class="bg-primary text-white">重要的背景顏色。</p>
  <p class="bg-success text-white">執(zhí)行成功背景顏色。</p>
  <p class="bg-info text-white">信息提示背景顏色。</p>
  <p class="bg-warning text-white">警告背景顏色</p>
  <p class="bg-danger text-white">危險(xiǎn)背景顏色。</p>
  <p class="bg-secondary text-white">副標(biāo)題背景顏色。</p>
  <p class="bg-dark text-white">深灰背景顏色。</p>
  <p class="bg-light text-dark">淺灰背景顏色。</p>
</div>
</body>
</html>


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)