目录

Basics

描述 (Description)

要创建粘性类型容器,请在类中包含类.sticky[data-sticky] 。 在容器中,粘性元素应该在确定网格布局和大小时进行包装。

例子 (Example)

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

<!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>Sticky Basics</title>
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.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>Sticky Basics Example</h2>
      <div class = "row">
         <div class = "columns small-12">
            <div class = "columns small-6" id = "sticky_example">
               <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed 
                  do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
                  Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
                  nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
                  in reprehenderit in voluptate velit esse cillum dolore eu fugiat
                  nulla pariatur. Excepteur sint occaecat cupidatat non proident,
                  sunt in culpa qui officia deserunt mollit anim id est laborum.
               </p>
               <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
                  sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                  Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris 
                  nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
                  reprehenderit in voluptate velit esse cillum dolore eu fugiat 
                  nulla pariatur. Excepteur sint occaecat cupidatat non proident, 
                  sunt in culpa qui officia deserunt mollit anim id est laborum.
               </p>
               <p>Lorem Ipsum is simply dummy text of the printing and typesetting
                  industry. Lorem Ipsum has been the industry's standard dummy text
                  ever since the 1500s, when an unknown printer took a galley of type
                  and scrambled it to make a type specimen book. It has survived not
                  only five centuries, but also the leap into electronic typesetting,
                  remaining essentially unchanged. It was popularised in the 1960s with
                  the release of Letraset sheets containing Lorem Ipsum passages, and
                  more recently with desktop publishing software like Aldus PageMaker
                  including versions of Lorem Ipsum.
               </p>
               <p>Lorem Ipsum is simply dummy text of the printing and typesetting
                  industry. Lorem Ipsum has been the industry's standard dummy 
                  text ever since the 1500s, when an unknown printer took a galley of type 
                  and scrambled it to make a type specimen book. It has survived not only 
                  five centuries, but also the leap into electronic typesetting, remaining 
                  essentially unchanged. It was popularised in the 1960s with the release 
                  of Letraset sheets containing Lorem Ipsum passages, and more recently 
                  with desktop publishing software like Aldus PageMaker including versions 
                  of Lorem Ipsum.
               </p>
               <p>Lorem Ipsum is simply dummy text of the printing and typesetting
                  industry. Lorem Ipsum has been the industry's standard dummy 
                  text ever since the 1500s, when an unknown printer took a galley of type 
                  and scrambled it to make a type specimen book. It has survived not only 
                  five centuries, but also the leap into electronic typesetting, remaining 
                  essentially unchanged. It was popularised in the 1960s with the release 
                  of Letraset sheets containing Lorem Ipsum passages, and more recently 
                  with desktop publishing software like Aldus PageMaker including versions 
                  of Lorem Ipsum.
               </p>
               <p>Lorem Ipsum is simply dummy text of the printing and typesetting
                  industry. Lorem Ipsum has been the industry's standard dummy 
                  text ever since the 1500s, when an unknown printer took a galley of type 
                  and scrambled it to make a type specimen book. It has survived not only 
                  five centuries, but also the leap into electronic typesetting, remaining 
                  essentially unchanged. It was popularised in the 1960s with the release 
                  of Letraset sheets containing Lorem Ipsum passages, and more recently 
                  with desktop publishing software like Aldus PageMaker including versions 
                  of Lorem Ipsum.
               </p>
               <p>Lorem Ipsum is simply dummy text of the printing and typesetting
                  industry. Lorem Ipsum has been the industry's standard dummy 
                  text ever since the 1500s, when an unknown printer took a galley of type 
                  and scrambled it to make a type specimen book. It has survived not only 
                  five centuries, but also the leap into electronic typesetting, remaining 
                  essentially unchanged. It was popularised in the 1960s with the release 
                  of Letraset sheets containing
               </p>
            </div>
            <div class = "columns small-6 right" data-sticky-container>
               <div class = "sticky" data-sticky data-anchor = "sticky_example">
                  <img class = "thumbnail" src = "/foundation/images/foundation-plugin/small.jpg">
               </div>
            </div>
         </div>
      </div>
      <div>
         <p>Lorem Ipsum is simply dummy text of the printing and typesetting 
            industry. Lorem Ipsum has been the industry's standard dummy text ever 
            since the 1500s, when an unknown printer took a galley of type and 
            scrambled it to make a type specimen book. It has survived not only 
            five centuries, but also the leap into electronic typesetting,
            remaining essentially unchanged. It was popularised in the 1960s with
            the release of Letraset sheets containing Lorem Ipsum passages, and
            more recently with desktop publishing software like Aldus 
            PageMaker including versions of Lorem Ipsum.
         </p>
         <p>Lorem Ipsum is simply dummy text of the printing and typesetting 
            industry. Lorem Ipsum has been the industry's standard dummy text ever
            since the 1500s, when an unknown printer took a galley of type and
            scrambled it to make a type specimen book. It has survived not only
            five centuries, but also the leap into electronic typesetting,
            remaining essentially unchanged. It was popularised in the 1960s with
            the release of Letraset sheets containing Lorem Ipsum is simply dummy
            text of the printing and typesetting industry. Lorem Ipsum has been
            the industry's standard dummy text ever since the 1500s, when 
            an unknown printer took a galley of type and scrambled it to make a
            type specimen book. It has survived not only five centuries, but also
            the leap into electronic typesetting, remaining essentially unchanged.
            It was popularised in the 1960s with the release of Letraset sheets
            containing Lorem Ipsum passages, and more recently with desktop
            publishing software like Aldus PageMaker including versions of
            Lorem Ipsum.
         </p>
      </div>
      <script>
         $(document).ready(function() {
            $(document).foundation();
         })
      </script>
   </body>
</html>

输出 (Output)

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

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

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

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