Foundation - 內部標籤



描述

您可以使用內部標籤顯示處於活動和非活動狀態的開關文字。.switch-active 用於表示開關處於開啟狀態,.switch-inactive 用於表示開關處於關閉狀態。活動/非活動文字包含在開關的 <lable> 中。

示例

以下示例演示了在 Foundation 中使用 內部開關標籤

<html>
   <head>
      <title>Inner Labels</title>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/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/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" crossorigin="anonymous"></script>

   </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>
         $(document).ready(function() {
            $(document).foundation();
         })
      </script>
   </body>
</html>

輸出

讓我們執行以下步驟,瞭解上面給出的程式碼是如何工作的 -

  • 將上述給出的 HTML 程式碼儲存在 inner_labels.html 檔案中。

  • 在瀏覽器中開啟此 HTML 檔案,如下所示顯示輸出。

foundation_basic_controls.htm
廣告
© . All rights reserved.