Foundation 按鈕


按鈕樣式

Foundation 提供了 6 種按鈕樣式。 .button 類別創建了一個藍色的按鈕並附有內邊距。不同顏色按鈕類別為: .secondary, .success, .info, .warning.alert :

實例

<!DOCTYPE html>
<html>
<head>
  <title>Foundation 实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css">
  <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script>
</head>
<body>
<div style="padding:20px;">
  <h2>按钮样式</h2>
  <button type="button" class="button">Default</button>
  <button type="button" class="button secondary">Secondary</button>
  <button type="button" class="button success">Success</button>
  <button type="button" class="button info">Info</button>
  <button type="button" class="button warning">Warning</button>
  <button type="button" class="button alert">Alert</button>
</div>

</body>
</html>

運行實例»

點擊"運行實例"按鈕查看線上實例

按鈕類別可以使用在<a>, <button>, 或 <input> 元素:

實例

#
<!DOCTYPE html>
<html>
<head>
  <title>Foundation 实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css">
  <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script>
</head>
<body>

<div style="padding:20px;">
  <h2>按钮元素</h2>
  <a href="#" class="button info" role="button">链接按钮</a>
  <button type="button" class="button info">按钮</button>
  <input type="button" class="button info" value="Input 按钮">
  <input type="submit" class="button info" value="Submit 按钮">
</div>

</body>
</html>

運行實例»##點擊"運行實例" 按鈕查看線上實例

Note#為什麼將a 標籤的href 設為# ?
當我們不希望連結點擊跳轉並得到"404" 頁面時,我們可以將 a 標籤的 href 設定為 #。

按鈕大小

我們可以使用

.large, .small .tiny 類別來設定按鈕大小:

實例

<!DOCTYPE html>
<html>
<head>
  <title>Foundation 实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css">
  <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script>
</head>
<body>

<div style="padding:20px;">
  <h2>按钮大小</h2>
  <button type="button" class="button large">Large</button>
  <button type="button" class="button">Default</button>
  <button type="button" class="button small">Small</button>
  <button type="button" class="button tiny">Tiny</button>
</div>

</body>
</html>

運行實例»點擊"運行實例" 按鈕查看線上實例


圓角按鈕

可以使用

.radius.round 類別來設定圓角按鈕:

實例

<!DOCTYPE html>
<html>
<head>
  <title>Foundation 实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css">
  <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script>
</head>
<body>

<div style="padding:20px;">
  <h2>圆角按钮</h2>
  <button type="button" class="button">Default Button</button>
  <button type="button" class="button radius">Radius Button</button>
  <button type="button" class="button round">Round Button</button>
</div>

</body>
</html>

運行實例»點擊"運行實例"按鈕查看線上實例


延展按鈕

可以使用

.expand 類別來設定按鈕的寬頻為100%:

實例

<!DOCTYPE html>
<html>
<head>
  <title>Foundation 实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css">
  <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script>
</head>
<body>

<div style="padding:20px;">
  <h2>延展按钮</h2>
  <button type="button" class="button">Default</button>
  <button type="button" class="button expand">Expanded Button</button>
</div>

</body>
</html>

運行實例»點擊"運行實例"按鈕查看線上實例


停用按鈕

可以使用

.disabled 類別來設定按鈕不可點選:

實例

<!DOCTYPE html>
<html>
<head>
  <title>Foundation 实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css">
  <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script>
  <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script>
</head>
<body>

<div style="padding:20px;">
  <h2>禁用按钮</h2>
  <button type="button" class="button">Default Button</button>
  <button type="button" class="button disabled">Disabled Button</button>
</div>

</body>
</html>

執行實例»點擊"運行實例" 按鈕查看線上實例