目录

切换CSS类(Toggle a CSS class)

描述 (Description)

通过在元素中使用属性data-toggler data-animate ,可以将动画效果应用于切换。 使用Motion UI类,元素进出视图。

例子 (Example)

以下示例演示了在Foundation中使用toggler插件 -

<!doctype html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1.0" />
      <title>Reveal Animations</title>
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.css">
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/motion-ui/1.1.1/motion-ui.css">
      <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>
   </head>
   <body>
      <h2>Example of Toggle with animation</h2>
      <button class = "button" data-toggle = "toggle">Toggle Panel</button>
      <div class = "callout" id = "toggle" data-toggler data-animate = "hinge-in-from-top slide-out-right" style = "background-color:#8BD6EE;">
         <h4>Welcome to IoWiki</h4>
         <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>

输出 (Output)

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

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

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

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