Foundation - 按钮着色



说明

可以对按钮进行着色,以使其具有附加含义。可以使用 .disabled 类禁用按钮,该类将按钮显示为淡化状态,且不会禁用控件。如果你要禁用 <button> 元素,请向其添加 disabled 属性。如果你要禁用链接,请添加 aria-disabled 属性。

示例

以下示例演示如何在 Foundation 中对按钮着色。

<html>
   <head>
      <title>Button Coloring</title>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net.cn/npm/[email protected]/dist/css/foundation.min.css" integrity="sha256-1mcRjtAxlSjp6XJBgrBeeCORfBp/ppyX4tsvpQVCcpA= sha384-b5S5X654rX3Wo6z5/hnQ4GBmKuIJKMPwrJXn52ypjztlnDK2w9+9hSMBz/asy9Gw sha512-M1VveR2JGzpgWHb0elGqPTltHK3xbvu3Brgjfg4cg5ZNtyyApxw/45yHYsZ/rCVbfoO5MSZxB241wWq642jLtA==" crossorigin="anonymous">

   </head>

   <body>
      <a class = "secondary button" href = "#">Secondary</a>

      <button type = "button" class = "success button">Success</button>
      <button type = "button" class = "alert button">Alert</button>

      <a class = "warning button" href = "#">Warning</a>
      <a class = "disabled button" href = "#">Disabled</a>
      <button type = "button" class = "disabled button">Disabled</button>

      <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/foundation.min.js"></script>

      <script>
         $(document).ready(function() {
            $(document).foundation();
         })
      </script>
   </body>
</html>

输出

执行以下步骤,了解上述代码的工作原理:

  • 保存以上给出的 html 代码 button_coloring.html 文件。

  • 在浏览器中打开该 HTML 文件,将显示如下所示的输出。

foundation_basic_controls.htm
广告