99re热视频这里只精品,久久久天堂国产精品女人,国产av一区二区三区,久久久精品成人免费看片,99久久精品免费看国产一区二区三区

Bootstrap 警告和錯(cuò)誤

2018-11-03 17:19 更新

Bootstrap 警告和錯(cuò)誤

簡(jiǎn)介

Bootstrap 允許您為網(wǎng)站或 app 的成功執(zhí)行、警告和錯(cuò)誤信息定義樣式。在本教程中,您將學(xué)習(xí)如何做到這點(diǎn)。

創(chuàng)建一個(gè)簡(jiǎn)單的警告信息

使用 CSS class "alert",位于 bootstrap.css 中的行號(hào) 2123 到 2175(版本 2.0.1),您可以創(chuàng)建一個(gè)簡(jiǎn)單警告信息。您可以為它添加一個(gè)可選的關(guān)閉圖標(biāo)。

當(dāng)您點(diǎn)擊警告框中的關(guān)閉圖標(biāo)時(shí),警告框關(guān)閉。要想實(shí)現(xiàn)這個(gè)交互效果,您必須添加兩個(gè) JavaScript 文件 jquery.js 和 alert.js。您可以把它們添加到 body 元素關(guān)閉標(biāo)簽前面。

Bootstrap 創(chuàng)建一個(gè)簡(jiǎn)單的警告信息的實(shí)例

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 
<title>Basic alerts with twitter bootstrap</title> 
<meta name="description" content="Creating basic alerts with Twitter Bootstrap. Examples of alerts and errors with Twitter Bootstrap"> 
<link href="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet"> 
<style type="text/css">
body {
padding: 50px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="span4">
<div class="alert">
  <a class="close" data-dismiss="alert">×</a>
  <strong>Warning!</strong> Best check yo self, you're not looking too good.
</div>
</div>
</div>
</div>
<script src="twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
<script src="twitter-bootstrap-v2/docs/assets/js/bootstrap-alert.js"></script>
</body>
</html>
            

請(qǐng)注意,行號(hào) 18 到 21 之間的代碼是必需的。這些僅是為了實(shí)例演示。

輸出

basic-alert

在線查看

在不同的瀏覽器窗口查看上面實(shí)例。

擴(kuò)展簡(jiǎn)單的警告信息

通過(guò)另外兩個(gè) CSS classes "alert-block " 和 "alert-heading",您可以擴(kuò)展前面演示的簡(jiǎn)單的警告信息。它讓您更好地控制要顯示的文本,而且您可以在警告文本前添加文本標(biāo)題。

當(dāng)您點(diǎn)擊警告框中的關(guān)閉圖標(biāo)時(shí),警告框關(guān)閉。要想實(shí)現(xiàn)這個(gè)交互效果,您必須添加兩個(gè) JavaScript 文件 jquery.js 和 alert.js。您可以把它們添加到 body 元素關(guān)閉標(biāo)簽前面。

Bootstrap 擴(kuò)展簡(jiǎn)單的警告信息的實(shí)例

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 
<title>Extending simple alert with twitter bootstrap</title> 
<meta name="description" content="Extending simple alert with twitter bootstrap."> 
<link href="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet"> 
<style type="text/css">
body {
padding: 50px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="span4">
<div class="alert alert-block">
  <a class="close" data-dismiss="alert">×</a>
  <h4 class="alert-heading">Warning!</h4>
 What are you doing?! this will delete all files!!
</div>
</div>
</div>
</div>
<script src="twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
<script src="twitter-bootstrap-v2/docs/assets/js/bootstrap-alert.js"></script>
</body>
</html>
            

輸出

extended-alert

在線查看

在不同的瀏覽器窗口查看上面實(shí)例。

在錯(cuò)誤(error)、成功(success)、信息(information)發(fā)生時(shí)創(chuàng)建警告

Bootstrap 允許您在錯(cuò)誤或危險(xiǎn)、成功和信息發(fā)生時(shí)創(chuàng)建何時(shí)的警告。對(duì)于錯(cuò)誤(error),您需要 CSS class "alert-error"。對(duì)于成功(success),您需要 "alert-success" class。對(duì)于信息(information),您需要 class "alert-info"。當(dāng)然,就像前面的實(shí)例中說(shuō)明的一樣,您需要 JS 文件 jquery.js 和 alert.js。

Bootstrap 錯(cuò)誤、成功和信息的警告實(shí)例

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 
<title>Example alerts on error success and information with Twitter bootstrap</title> 
<meta name="description" content="Example alerts on error success and information with Twitter bootstrap."> 
<link href="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet"> 
<style type="text/css">
body {
padding: 50px;
}
</style>
</head>
<body>
<div class="alert alert-error">
  <a class="close" data-dismiss="alert">×</a>
  <strong>Error!</strong>This is a fatal error.
</div>
<div class="alert alert-success">
  <a class="close" data-dismiss="alert">×</a>
  <strong>Success!</strong>You have successfully done it.
</div>
<div class="alert alert-info">
  <a class="close" data-dismiss="alert">×</a>
  <strong>Info!</strong>Watch this, but you may forget.
</div>
<script src="twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
<script src="twitter-bootstrap-v2/docs/assets/js/bootstrap-alert.js"></script>
</body>
</html>
            

輸出

alert-error-success-info

在線查看

在不同的瀏覽器窗口查看上面實(shí)例。

點(diǎn)擊這里,下載本教程中使用到的所有 HTML、CSS、JS 和圖片文件。

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

掃描二維碼

下載編程獅App

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

編程獅公眾號(hào)