Foundation - 外掛標記為可關閉



說明

包含 data-closable 屬性可關閉元素;動畫效果也可以在元素退出時應用。data-close 屬性會在你想要在元素內新增點選觸發器時包含。

示例

以下示例演示了在 Foundation 中使用切換器外掛——

<!doctype html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1.0" />
      <title>Foundation Template</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>

      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/motion-ui/1.1.1/motion-ui.css">
   </head>

   <body>
      <h2>Example of Toggle with closable</h2>

      <div class = "callout" data-closable = "spin-out" style = "background-color:#8BD6EE;">
         <button class = "close-button" data-close>×</button>
         <p>Lorem Ipsum is simply dummy text of the printing and typesetting
            industry.Lorem Ipsum has been the industry's standard dummy text.
         </p>
      </div>

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

輸出

讓我們執行以下步驟,瞭解如何使上述給定的程式碼正常工作——

  • 儲存上述給定的 HTML 程式碼 closable.html 檔案。

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

foundation_plugins.htm
廣告
© . All rights reserved.