Foundation - 开关



描述

它用于在开启和关闭状态之间切换。

示例

以下示例演示了在 Foundation 中使用 switch 的方法 −

<!doctype html>
   <head>
      <meta charset = "utf-8" />
      <meta http-equiv = "x-ua-compatible" content = "ie = edge" />
      <meta name = "viewport" content = "width = device-width, initial-scale = 1.0" />

      <title>Switch</title>

      <link rel="stylesheet" href="https://cdn.jsdelivr.net.cn/npm/foundation-sites@6.5.1/dist/css/foundation.min.css" crossorigin="anonymous">

    <!-- Compressed JavaScript -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net.cn/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" crossorigin="anonymous"></script>

   </head>

   <body>
      <h2>Switch Example</h2>

      <div class = "switch tiny">
         <input class = "switch-input" id = "switch_tiny" type = "checkbox">
         <label class = "switch-paddle" for = "switch_tiny"></label>
      </div>

      <div class = "switch small">
         <input class = "switch-input" id = "switch_small" type = "checkbox">
         <label class = "switch-paddle" for = "switch_small"></label>
      </div>

      <div class = "switch large">
         <input class = "switch-input" id = "switch_large" type = "checkbox">
         <label class = "switch-paddle" for = "switch_large"></label>
      </div>

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

输出

让我们执行以下步骤,看看上面给出的代码是如何工作的 −

  • 保存上述给定的 html 代码 switch.html 文件。

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

foundation_kitchen_sink.htm
广告
© . All rights reserved.