首页 > 其他分享 >TreeSaver 使用教程整理——Step 2: Adding Basic UI

TreeSaver 使用教程整理——Step 2: Adding Basic UI

时间:2023-06-27 20:01:12浏览次数:48  
标签:Adding bottom top controls TreeSaver Basic position font absolute

请首先阅读前一篇教程:

TreeSaver 使用教程整理——Step 1: Getting Started

Step 2: Adding Basic UI

我们上一步实现的网页有了一个最最简单的功能,这一步我们将在上一步基础上添加切换分页的按钮以及显示当前页面信息。

请Copy上一步的内容,并对下面文件做如下修改:

 

对资源文件(resources.html)的修改

资源文件的 chrome 区域修改成如下信息:

<div class="chrome">
  <div class="viewer">
  </div>
  <div class="controls">
    <div class="pagewidth">
      <span class="pagenumbers">
        <span data-bind="pagenumber">1</span> /
        <span data-bind="pagecount">5</span>
      </span>
      <button class="prev">Prev</button>
      <button class="next">Next</button>
    </div>
  </div>
</div>

说明:

我们在 step1的下面代码基础上,增加了如下功能: 显示内容区域下增加了两个功能:

<div class="chrome">
      <div class="viewer"></div>
    </div>
  • 分页信息,我们通过数据绑定了当前页数和总页数。
    Page numbers: Adding data-bind="pagenumber" to an element will cause it to be automatically updated with the current page number (use data-bind="pagecount" for the total number of pages).
  • 我们增加了前一页和后一页的功能按钮。
    Previous & Next Buttons: Adding a CSS class of next or prev automatically adds page turning ability to any element when clicked.

对于样式 style.css 文件,我们做了如下调整:

.treesaver body {
  /* Hide scrollbars */
  overflow: hidden;
  /* Use full body canvas */
  margin: 0;
  border: 0;
  padding: 0;
}
.chrome, .viewer, .grid, .column, .container {
  /* Manually position everything */
  position: absolute;
  /* Make sure seams aren't visible */
  overflow: hidden;
  /* Set the base vertical grid */
  line-height: 20px;
}
/* Stretch the viewer to fill the screen */
.viewer {
  top: 0;
  bottom: 40px;
  left: 0;
  right: 0;
}
.grid {
  width: 300px;
  border: 1px solid #ccc;
  margin: 9px;
  opacity: .25
}
.column {
  width: 280px;
  top: 5px;
  bottom: 5px;
  left: 5px;
}
#currentPage {
  opacity: 1;
}
.controls {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  height: 30px;
  line-height: 30px;
  font-family: Helvetica, Sans-Serif;
}
.pagenumbers {
  display: block;
  text-align: center;
  color: #999;
  font-size: 12px;
  font-weight: bold;
}
.controls .pagewidth {
  margin: 0 auto;
  position: relative;
}
.controls .next {
  position: absolute;
  right: 0;
  top: 0;
}
.controls .prev {
  position: absolute;
  left: 0;
  top: 0;
}

说明:

  • 我们把 .viewer 的 bottom 设置成 40px; 这个区域用于显示我们的分页信息与分页按钮,
    The CSS here is fairly straightforward, the most important part is that we changed the .viewer clause to have bottom: 40px. Treesaver places all pages within this element, using the current dimensions in order to calculate the amount of space available for layout. We needed to adjust the bottom in order to give space for the buttons and page numbers.
  • 我们把 .grid  的不透明特性:opacity设置成 .25 。同时当前选择的不透明特性设置成 1,这使得整个页面突出显示了当前页面。
    The CSS also sets opacity: .25 on any .grid, while setting opacity: 1 on #currentPage. This makes the next and previous pages translucent, making the current page more prominent.
  • 我们把增加的按钮等给了CSS属性,如下就是新增的CSS属性:
    We finish this step off by adding a bit of styling to the buttons, using the CSS3 button styling by ubuwaits:
#currentPage {
  opacity: 1;
}
.controls {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  height: 30px;
  line-height: 30px;
  font-family: Helvetica, Sans-Serif;
}
.pagenumbers {
  display: block;
  text-align: center;
  color: #999;
  font-size: 12px;
  font-weight: bold;
}
.controls .pagewidth {
  margin: 0 auto;
  position: relative;
}
.controls .next {
  position: absolute;
  right: 0;
  top: 0;
}
.controls .prev {
  position: absolute;
  left: 0;
  top: 0;
}
  • 这时候的演示效果如下:

TreeSaver 使用教程整理——Step 2: Adding Basic UI_CSS


多了导航按钮和当前页面信息,同时突出显示当前页面

参考资料:

https://github.com/Treesaver/treesaver/wiki/Walkthrough

标签:Adding,bottom,top,controls,TreeSaver,Basic,position,font,absolute
From: https://blog.51cto.com/u_15588078/6565325

相关文章

  • TreeSaver 使用教程整理——Step 1: Getting Started
    TreeSaver介绍Treesaver是一个开源的JavaScript框架,用来创建杂志风格的网页布局。 为何要整理这个系列的文章下面的教程整理自:https://github.com/Treesaver/treesaver/wiki/Walkthrough,也许是这个框架目前才刚刚起步,它的文档很成问题,文档中一些链接不能下载,源代码中欠缺一......
  • Visual Basic(简称VB)是一种编程语言,由微软公司开发。它是基于事件驱动的编程语言,主要用
    VisualBasic(简称VB)是一种编程语言,由微软公司开发。它是基于事件驱动的编程语言,主要用于Windows操作系统上的应用程序开发。在VisualBasic中,可以使用图形用户界面(GUI)来创建各种应用程序,包括桌面应用程序、数据库应用程序、Web应用程序等。VisualBasic提供了许多现成的控件和工......
  • TreeSaver.js 的工作流程逻辑
    Treesaver是浏览器大小尺寸敏感(size-sensitive)的,会就着当前的浏览器尺寸(browsersize),选用不同的分栏表格(grid)做排版。初始化TreeSaver.js框架的入口源代码在后面可以看到:https://github.com/Treesaver/treesaver/blob/master/src/init.js这里的代码用到了Google开发的JS库:Closur......
  • Win7环境下TreeSaver编译环境的搭配
    首先你需要先搭配出”Win7环境下TreeSaver例子环境的搭配”然后才能继续下一步编译环境。例子环境搭配后,你可以在源代码目录下执行paver命令,搭配例子测试环境,也可以执行paverdebug生成带调试注释信息的treesaver脚本,当然也可以使用paverclean删除生成的文件。这些可以......
  • Android 的Margin和Padding属性以及支持的长度单位
    Android的Margin和Padding跟Html的是一样的。如下图所示:黄色部分为Padding,灰色部分为Margin。通俗的理解Padding为内边框,Margin为外边框对应的属性为android:layout_marginBottom="25dip"android:layout_marginLeft="10dip"android:layout_marginTop="10dip"an......
  • Beginning QA --- Basics and Related Concepts
    基本概念什么是QA?质量保证是以过程为中心的保证一个组织能够提供高质量产品的方法。什么是测试?为什么需要测试?测试是发现和标记缺陷的过程。所谓的缺陷是指实际结果和期望结果之间的任何差别。有的地方,测试也被认为是执行以找出错误为目的的程序的过程。测试是为了让产品达到以下......
  • 【数据库原理、编程与性能】Basic SQL Query Language
    文章目录1.HistoryofSQL2.CapabilitiesofSQL2.1综合统一2.2高度非过程化2.3面向集合的操作方式2.4SQL以同一种语法结构提供两种使用方式2.5语言简捷,易学易用3.SQL语句3.1Create语句3.2Select语句3.3Subquery语句3.3.1定义3.3.2Conception(概念)3.3.3predicate(谓词......
  • Linux command line basics: sudo
    Linuxcommandlinebasics:sudohttps://www.redhat.com/sysadmin/sudoWhatissudo?Sudostandsfor"superuserdo"andisthemasterkeytoyourhigh-privilegeadmintasks.Haveyouevertriedtoeditaconfigfileonlytoreceive"Permissi......
  • 【原】iOSCoreAnimation动画系列教程(一):CABasicAnimation【包会】
    【原】iOSCoreAnimation动画系列教程(一):CABasicAnimation【包会】 在iOS中,图形可分为以下几个层次: 越上层,封装程度越高,动画实现越简洁越简单,但是自由度越低;反之亦然。本文着重介绍CoreAnimation层的基本动画实现方案。在iOS中,展示动画可以类比于显示生活中的“拍电影”。拍电影有......
  • 启动word时总是弹出Microsoft Visual Basic运行错误提示框,解决方法如下
    1、启动word,找到加载项名称为:NEWebWordAddin.dotm,类型应该时是模版版,看其所在位置,我的电脑显示位置是:C:\Users\18308\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\LocalCache\Roaming\Microsoft\Word2、为保持原有数据   进入该位置,将STARTUP改成bak_......