Framework7 - 固定布局



描述

在此布局中,导航栏和工具栏将被固定,并且在页面上无法滚动。每个页面也可以有自己的导航栏和工具栏。

示例

以下示例演示了在 Framework7 中使用固定布局。以下示例中的导航栏和工具栏看起来是固定的。

首先,我们将创建我们的 **fixed_layout.html** 文件。

<!DOCTYPE html>
<html>
   
   <head>
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width = device-width, initial-scale = 1, 
         maximum-scale = 1, minimum-scale = 1, user-scalable = no, minimal-ui" />
      <meta name = "apple-mobile-web-app-capable" content = "yes" />
      <meta name = "apple-mobile-web-app-status-bar-style" content = "black" />
      <title>Fixed Layout</title>
      <link rel = "stylesheet" 
         href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.min.css" />
      <link rel = "stylesheet" 
         href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.colors.min.css" />
   </head>
   
   <body>
      <div class = "views">
         <div class = "view view-main">
            <div class = "pages">
               
               <div data-page = "home" class = "page navbar-fixed toolbar-fixed">
                  <div class = "navbar">
                     <div class = "navbar-inner">
                        <div class = "left"></div>
                        <div class = "center">Fixed Navbar</div>
                        <div class = "right"></div>
                     </div>
                  </div>
                  
                  <div class = "page-content">
                     <div class = "content-block">
                        <p><a href = "fixed_layout-services.html">Services page</a></p>
                        
                        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
                           Suspendisse at nibh felis. Nunc consequat diam et tellus tempor gravida. 
                           Donec hendrerit aliquet risus, ut tempor purus dictum sit amet. Integer sit 
                           amet lacus eget ipsum pulvinar interdum. Proin semper turpis sed placerat dapibus. 
                           Sed iaculis id nibh a viverra. Sed vitae tellus sed purus lacinia dignissim. 
                           Aenean sagittis interdum leo in molestie. Aliquam sodales in diam eu consectetur. 
                           Sed posuere a orci id imperdiet.</p>
                        
                        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
                           Suspendisse at nibh felis. Nunc consequat diam et tellus tempor gravida. 
                           Donec hendrerit aliquet risus, ut tempor purus dictum sit amet. Integer 
                           sit amet lacus eget ipsum pulvinar interdum. Proin semper turpis sed placerat 
                           dapibus. Sed iaculis id nibh a viverra. Sed vitae tellus sed purus lacinia 
                           dignissim. Aenean sagittis interdum leo in molestie. Aliquam sodales in diam 
                           eu consectetur. Sed posuere a orci id imperdiet.</p>
                        
                        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
                           Suspendisse at nibh felis. Nunc consequat diam et tellus tempor gravida. 
                           Donec hendrerit aliquet risus, ut tempor purus dictum sit amet. Integer sit 
                           amet lacus eget ipsum pulvinar interdum. Proin semper turpis sed placerat dapibus. 
                           Sed iaculis id nibh a viverra. Sed vitae tellus sed purus lacinia dignissim. 
                           Aenean sagittis interdum leo in molestie. Aliquam sodales in diam eu consectetur. 
                           Sed posuere a orci id imperdiet.</p>
                     </div>
                  </div>
                  
                  <div class = "toolbar">
                     <div class = "toolbar-inner">
                        <a href = "#" class = "link">Link 1</a>
                        <a href="#" class="link">Link 1</a>
                     </div>
                  </div>
                  
               </div>
            </div>
         </div>
      </div>
      
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>
      
      <script>
         var myApp = new Framework7();
         var mainView = myApp.addView('.view');
      </script>
   </body>
   
</html>

接下来,创建 HTML 页面,即 **fixed_layout-services.html**,如下所示:

<div class = "views">
   <div class = "view view-main">
      <div class = "pages">
         <div data-page = "services" class = "page navbar-fixed toolbar-fixed">
         
            <div class = "navbar">
               <div class = "navbar-inner">
                  <div class = "center">Services Page</div>
               </div>
            </div>
            
            <div class = "page-content">
               <div class = "content-block">
                  <p><a href = "bars-fixed-index.html" class = "back">Go back to Home page</a></p>
                  
                  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
                     Suspendisse at nibh felis. Nunc consequat diam et tellus tempor gravida. 
                     Donec hendrerit aliquet risus, ut tempor purus dictum sit amet. Integer sit 
                     amet lacus eget ipsum pulvinar interdum. Proin semper turpis sed placerat dapibus. 
                     Sed iaculis id nibh a viverra. Sed vitae tellus sed purus lacinia dignissim. 
                     Aenean sagittis interdum leo in molestie. Aliquam sodales in diam eu consectetur. 
                     Sed posuere a orci id imperdiet.</p>
                  
                  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse at nibh felis. 
                     Nunc consequat diam et tellus tempor gravida. Donec hendrerit aliquet risus, ut tempor purus 
                     dictum sit amet. Integer sit amet lacus eget ipsum pulvinar interdum. Proin semper turpis 
                     sed placerat dapibus. Sed iaculis id nibh a viverra. Sed vitae tellus sed purus lacinia dignissim.
                     Aenean sagittis interdum leo in molestie. Aliquam sodales in diam eu consectetur. Sed posuere 
                     a orci id imperdiet.</p>
                  
                  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse at nibh felis. 
                     Nunc consequat diam et tellus tempor gravida. Donec hendrerit aliquet risus, ut tempor purus 
                     dictum sit amet. Integer sit amet lacus eget ipsum pulvinar interdum. Proin semper turpis sed
                     placerat dapibus. Sed iaculis id nibh a viverra. Sed vitae tellus sed purus lacinia 
                     dignissim. Aenean sagittis interdum leo in molestie. Aliquam sodales in diam eu consectetur. 
                     Sed posuere a orci id imperdiet.</p>
                  
                  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse at nibh felis. 
                     Nunc consequat diam et tellus tempor gravida. Donec hendrerit aliquet risus, ut tempor purus 
                     dictum sit amet. Integer sit amet lacus eget ipsum pulvinar interdum. Proin semper turpis sed 
                     placerat dapibus. Sed iaculis id nibh a viverra. Sed vitae tellus sed purus lacinia dignissim.
                     Aenean sagittis interdum leo in molestie. Aliquam sodales in diam eu consectetur. Sed posuere 
                     a orci id imperdiet.</p>
               </div>
            </div>
            
            <div class = "toolbar">
               <div class = "toolbar-inner">
                  <a href = "#" class = "link">Service link 1</a>
                  <a href = "#" class = "link">Service link 2</a>
               </div>
            </div>
         
         </div>
      </div>
   </div>
</div>

输出

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

  • 将上面给出的 html 代码保存为 **fixed_layout.html** 文件,放在服务器根文件夹中。

  • 打开此 HTML 文件,地址为 https://127.0.0.1/fixed_layout.html,输出结果如下所示。

  • 当您滚动页面时,导航栏和工具栏将被固定,并且在屏幕上可见。

您可以为所有页脚链接创建单独的页面。

framework7_layouts.htm
广告