目录

Inner Labels

描述 (Description)

您可以使用内部标签显示活动和非活动开关文本。 .switch-active用于指示交换机已打开,而.switch-inactive用于指示交换机已关闭。 活动/非活动文本包含在交换机的《label》中。

例子 (Example)

以下示例演示了在Foundation中使用inner label for switch

<html>
   <head>
      <title>Inner Labels</title>
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.css">
   </head>
   <body>
      <p>Would you like to follow us?</p>
      <div class = "switch large">
         <input class = "switch-input" id = "inner_label" type = "checkbox" name = "demoSwitch">
         <label class = "switch-paddle" for = "inner_label">
            <span class = "show-for-sr">Would you like to follow us?</span>
            <span class = "switch-active" aria-hidden = "true">Yes</span>
            <span class = "switch-inactive" aria-hidden = "true">No</span>
         </label>
      </div>
      <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>

输出 (Output)

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

  • 保存上面给出的html代码inner_labels.html文件。

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

新页面打开
↑回到顶部↑
WIKI教程 @2018