Fixed Layout
优质
小牛编辑
123浏览
2023-12-01
描述 (Description)
在这种布局中,导航栏和工具栏将是固定的,不能滚动页面。 每一页还可以有自己的导航栏和工具栏。
例子 (Example)
下面的示例说明在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="#">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>
输出 (Output)
让我们来进行上面给出看看代码是如何工作的以下步骤 -
保存上面给出的HTML代码fixed_layout.html文件服务器在你的根文件夹。
打开这个HTML文件为http://localhost/fixed_layout.html和如下所示被显示的输出。
当您滚动页面,以及工具栏导航栏将是固定的,他们是在屏幕上可见。
您可以为所有的页脚链接的单独的页面。