Bootstrap 輔助類

本章將討論 Bootstrap 中的一些可能會派上用場的輔助類。

文本

以下不同的類展示了不同的文本顏色。如果文本是個鏈接鼠標移動到文本上會變暗:

描述示例
.text-muted"text-muted" 類的文本樣式嘗試一下
.text-primary"text-primary" 類的文本樣式嘗試一下
.text-success"text-success" 類的文本樣式嘗試一下
.text-info"text-info" 類的文本樣式嘗試一下
.text-warning"text-warning" 類的文本樣式嘗試一下
.text-danger"text-danger" 類的文本樣式嘗試一下

背景

以下不同的類展示了不同的背景顏色。 如果文本是個鏈接鼠標移動到文本上會變暗:

描述示例
.bg-primary表格單元格使用了 "bg-primary" 類嘗試一下
.bg-success表格單元格使用了 "bg-success" 類嘗試一下
.bg-info表格單元格使用了 "bg-info" 類嘗試一下
.bg-warning表格單元格使用了 "bg-warning" 類嘗試一下
.bg-danger表格單元格使用了 "bg-danger" 類嘗試一下

其他

描述示例
.pull-left元素浮動到左邊嘗試一下
.pull-right元素浮動到右邊嘗試一下
.center-block設置元素為 display:block 并居中顯示嘗試一下
.clearfix清除浮動嘗試一下
.show強制元素顯示嘗試一下
.hidden強制元素隱藏嘗試一下
.sr-only除了屏幕閱讀器外,其他設備上隱藏元素嘗試一下
.sr-only-focusable與 .sr-only 類結(jié)合使用,在元素獲取焦點時顯示(如:鍵盤操作的用戶)嘗試一下
.text-hide將頁面元素所包含的文本內(nèi)容替換為背景圖嘗試一下
.close顯示關閉按鈕嘗試一下
.caret顯示下拉式功能嘗試一下

更多示例

關閉圖標

使用通用的關閉圖標來關閉模態(tài)框和警告框。使用 class close 得到關閉圖標。

在線示例

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"> 
	<title>Bootstrap 示例 - 關閉圖標</title>
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<p>關閉圖標示例
	<button type="button" class="close" aria-hidden="true">&times;</button>
</p>
</body>
</html>
測試看看 ?/?

結(jié)果如下所示:

關閉圖標

aria-hidden="true" 主要是幫助殘障人士(如失明)使用識讀設備(自動讀取內(nèi)容并自動播放出來),播放到帶此屬性的內(nèi)容時會自動跳過,以免殘障人士混淆!

插入符

使用插入符表示下拉功能和方向。使用帶有 class caret 的 <span> 元素得到該功能。

在線示例

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"> 
	<title>Bootstrap 示例 - 插入符</title>
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<p>插入符示例
	<span class="caret"></span>
</p>
</body>
</html>
測試看看 ?/?

結(jié)果如下所示:

插入符

快速浮動

您可以分別使用 class pull-leftpull-right 來把元素向左或向右浮動。下面的示例演示了這點。

在線示例

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"> 
	<title>Bootstrap 示例 - 快速浮動</title>
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="pull-left">
	向左快速浮動
</div>
<div class="pull-right">
	向右快速浮動
</div>
</body>
</html>
測試看看 ?/?

結(jié)果如下所示:

快速浮動

如需對齊導航欄中的組件,請使用 .navbar-left.navbar-right 代替。請查看 Bootstrap 導航欄。

內(nèi)容居中

使用 class center-block 來居中元素。

在線示例

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Bootstrap 示例 - 居中內(nèi)容塊</title>
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="row">
	<div class="center-block" style="width:200px;background-color:#ccc;">
		這是 center-block 示例
   	</div>
</div>
</body>
</html>
測試看看 ?/?

結(jié)果如下所示:

居中內(nèi)容塊

清除浮動

如需清除元素的浮動,請使用 .clearfix class。

在線示例

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Bootstrap 示例 - 清除浮動</title>
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="clearfix"  style="background: #D8D8D8;border: 1px solid #000;padding: 10px;">
	<div class="pull-left" style="background:#58D3F7;">
      	向左快速浮動
   	</div>
   	<div class="pull-right" style="background: #DA81F5;">
      	向右快速浮動
   	</div>
</div>
</body>
</html>
測試看看 ?/?

結(jié)果如下所示:

清除浮動

顯示和隱藏內(nèi)容

您可以通過使用 class .show.hidden 來強行設置元素顯示或隱藏(包括屏幕閱讀器)。

在線示例

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Bootstrap 示例 - 顯示和隱藏內(nèi)容</title>
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="row" style="padding: 91px 100px 19px 50px;">
	<div class="show" style="margin-left:10px;width:300px;background-color:#ccc;">
      	這是 show class 的示例
   	</div>
   	<div class="hidden" style="width:200px;background-color:#ccc;">
      	這是 hide class 的示例
   	</div>
</div>
</body>
</html>
測試看看 ?/?

結(jié)果如下所示:

顯示和隱藏內(nèi)容

屏幕閱讀器

您可以通過使用 class .sr-only 來把元素對所有設備隱藏,除了屏幕閱讀器。

在線示例

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Bootstrap 示例 - 屏幕閱讀器</title>
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="row" style="padding: 91px 100px 19px 50px;">
	<form class="form-inline" role="form">
		<div class="form-group">
			<label class="sr-only" for="email">Email 地址</label>
			<input type="email" class="form-control" placeholder="Enter email">
		</div>
		<div class="form-group">
			<label class="sr-only" for="pass">密碼</label>
			<input type="password" class="form-control" placeholder="Password">
		</div>
	</form>
</div>
</body>
</html>
測試看看 ?/?

結(jié)果如下所示:

屏幕閱讀器

在這里,我們看到兩個 input 類型的 label 標簽都帶有 class sr-only,因此標簽將只對屏幕閱讀器可見。

丰满人妻一级特黄a大片,午夜无码免费福利一级,欧美亚洲精品在线,国产婷婷成人久久Av免费高清