【干货】教你如何利用fullPage.js以及move.js插件打造高端大气的网站效果!
前言:
如今我们经常能见到全屏网站,尤其是国外网站。这些网站用几幅很大的图片或色块做背景,再添加一些简单的内容,显得格外的高端大气上档次。
在学习过jQuery插件之后,才发现之前的很多网站特效完全可以借助jQuery插件来实现,今天我们来尝试使用move.js以及fullPage.js插件来制作一个“高端网站”。
网站效果展示如下:

- 支持鼠标滚动
- 支持前进后退和键盘控制
- 多个回调函数
- 支持手机、平板触摸事件
- 支持 CSS3 动画
- 支持窗口缩放
- 窗口缩放时自动调整
- 可设置滚动宽度、背景颜色、滚动速度、循环选项、回调、文本对齐方式等等
Move.js是一款简单小巧的模拟CSS3动画的JS插件。它可以完成CSS3的各种动画效果:移动、变形、倾斜、背景色渐变、旋转等。并且可以在动画中使用各种easing效果。
首先,我们再h5中写出基本结构主体,代码如下:
<body>
<div id="fullpage">
<div class="section" id="section1">
<h1>fullpage-演示iphone5C官网</h1>
<img src="img/iphone1.jpg" />
</div>
<div class="section" id="section2">
<img src="img/iphone2.png" class="img2" />
<img src="img/iphone3.png" class="img3" />
<img src="img/iphone4.png" class="img4" />
<div class="description">
<h1>A powerful plugin</h1>
<strong>fullPage.js</strong>
<br /> callbacks allow you to create amazing dynamic sites with a bit of imagination. This example tries to reproduce the Apple iPhone-5c website animations as an example of what fullPage.js is capable of.
</div>
</div>
<div class="section" id="section3">
<img src="img/iphone-red.png" class="red" />
<img src="img/iphone-yellow.png" class="yellow" />
<img src="img/iphone-blue.png" class="blue" /> <div class="description">
<h2>Amazing stuff</h2> Combining
<strong>fullPage.js</strong> with your own CSS styles and animations, you will be able to create something remarkable.
</div> </div>
<div class="section" id="section4"> <div class="description">
<h2>Just a demo</h2>
This is, of course, just a demo. I didn't want to spend much time on it. Don't expect it to work perfectly in all kind of screens. It has been designed to work on 1180px width or over on modern browsers with CSS3.
</div>
<img src="img/iphone-green.png" class="green" />
<img src="img/iphone-two.png" class="two" />
</div>
</div> </body>
tips:
在fullPage中,class为section表示一个屏幕。
section不能执行包裹在body中,必须使用一个div包裹所有的section。
section中的每一个slide表示一个横向幻灯片,可在当前屏中左右横向切换。
在CSS样式中,我们对各部分元素进行了定位和静态的页面布局设置,代码如下:
*{
margin: 0px;
padding: 0px;
}
#section1{
background-color: #F0F2F4;
overflow: hidden;
text-align: center;
}
#fullPage{
min-width: 1250px;
}
.section{
min-height: 650px;
}
#section1 h1{
font-size: 70px;
text-align: center;
margin: 60px 0px;
}
#section img{
width: 45%;
}
#section2{
position: relative;
overflow: hidden;
}
#section2 .description{
width: 370px;
position: absolute;
top: 200px;
right: 130px;
color: #808080;
font-size: 18px;
line-height: 35px;
}
#section2 .description h1{
font-size: 36px;
margin-bottom: 15px;
}
#section2 img{
height: 685px;
position: absolute;
transform: scale(0.6);
top: -17px;
}
#section2 .img3{
z-index:;
}
#section3{
position: relative;
overflow: hidden;
}
#section3 .description{
width: 500px;
position: absolute;
top: 200px;
right: 130px;
color: #808080;
font-size: 18px;
line-height: 35px;
}
#section3 .description h1{
font-size: 36px;
margin-bottom: 15px;
}
#section3 img{
position: absolute;
}
#section3 .red{
left: 250px;
top: 150px;
}
#section3 .yellow{
left: -40px;
bottom: -400px;
}
#section3 .blue{
bottom: -400px;
left: 550px;
}
#section4{
position: relative;
}
#section4 .green{
position: absolute;
left:250px;
top: 200px;
}
#section4 .description{
width: 90%;
position: absolute;
top: 100px;
left: 5%;
color: #808080;
font-size: 14px;
line-height: 25px;
text-align: center;
}
#section4 .description h2{
font-size: 36px;
margin-bottom: 15px;
}
#section4 .two{
position: absolute;
bottom: -230px;
left: 600px;
}
接下来便是导入需要的JS文件:
需要注意的地方是:fullPage.js必须在JQuery.js文件之后导入!而move.js使用的是原生JS语言,故没有要求。

在我们组建好网页布局之后,必须先选中包裹所有section的div的ID,并调用fullPage()方法,才能加载布局。
调用fullPage()方法之后,可以给函数传入对象类型的参数,设置fullPage的各种属性。
<script type="text/javascript">
$(function() {
$("#fullpage").fullpage({
navigation: true,
verticalCentered: false,
anchors: ["page1", "page2", "page3", "page4"],
onLeave: function(index, nextIndex, direction) {
switch(index) {
case 2:
move(".img2").x(0).duration(".7").delay(600).scale(0.8).end();
move(".img3").x(0).duration(".7").delay(600).scale(1).end()
move(".img4").x(0).duration(".7").delay(600).scale(0.8).end() break; case 3:
if(nextIndex!=4){
move(".red").y(0).duration("1").scale(1).end();
move(".yellow").y(0).duration("1").scale(0.8).end()
move(".blue").y(0).duration("1").scale(0.8).end() break;
}
case 4:
move(".green").y(0).duration("0.7").scale(1).end()
move(".two").y(0).duration("0.7").scale(0.9).skewY(0).end()
break; }
switch(nextIndex) {
case 2:
move(".img2").x(-35).duration(".7").delay(700).scale(0.8).end();
move(".img3").x(300).duration(".7").delay(700).scale(1).end()
move(".img4").x(700).duration(".7").delay(700).scale(0.8).end() break;
case 3: move(".red").y(-400).duration("1.2").scale(1).end();
move(".yellow").y(-400).duration("1.2").scale(0.8).end()
move(".blue").y(-400).duration("1.2").scale(0.8).end()
move(".green").y(-400).duration("1.2").scale(1).end()
move(".two").y(0).duration("0.7").scale(0.9).rotate(180).end()
break; }
} });
});
</script>
网站主题效果出来之后需要进行细致的调整,另外插件只是工具,提升自己能力的途径是尝试自己创作插件。
【干货】教你如何利用fullPage.js以及move.js插件打造高端大气的网站效果!的更多相关文章
- 教你如何利用threejs对3D模型皮肤进行DIY
一步一步教你如何利用threejs加载gltf模型来实现DIY换肤功能. 模型准备 模型制作 模型可以通过网上下载,也可以自己通过c4d.maya.blender等模型制作软件得到.这里就不叙述有关模 ...
- fullpage.js全屏滚动插件使用小结
刚做好公司网站,通过全屏滚动,显著提高了官网的浏览体验.遂总结一下使用fullpage.js的方法.欢迎指正 一. fullpage.js简介 fullpage.js是一套实现浏览器全屏滚动的js插件 ...
- 教你如何利用分布式的思想处理集群的参数配置信息——spring的configurer妙用
引言 最近LZ的技术博文数量直线下降,实在是非常抱歉,之前LZ曾信誓旦旦的说一定要把<深入理解计算机系统>写完,现在看来,LZ似乎是在打自己脸了.尽管LZ内心一直没放弃,但从现状来看,需要 ...
- FullPage.js全屏滚动插件学习总结
如今我们经常能见到全屏网站,尤其是国外网站.这些网站用几幅很大的图片或色块做背景,再添加一些简单的内容,显得格外的高端大气上档次.比如 iPhone 5C 的介绍页面(查看),QQ浏览器的官网站.如果 ...
- 教你如何利用xml格式的sitemap文件做好SEO
教你如何利用xml格式的sitemap文件做好SEO 浏览: | 更新:-- : 一般的网站中都有网站地图文件,它有HTML格式与XML格式,网站地图可以帮助搜索引擎抓取.帮助用户找到自己所需要的内容 ...
- 如何在我们项目中利用开源的图表(js chart)
最近觉得应该把自己在技术上的一些心得记录在博客里面跟大家分享,一起讨论,一起成长! 这篇随笔主要为介绍chart在项目中的运用,因为在我们看到一些开源的chart时候,是使 ...
- 利用修改div的位置+js对象存储div信息 实现简单的div自定义布局功能
原文:利用修改div的位置+js对象存储div信息 实现简单的div自定义布局功能 利用修改div的位置+js对象存储div信息 实现简单的div自定义布局功能1.在界面上添加几个checkbox和一 ...
- 【Python3爬虫】教你怎么利用免费代理搭建代理池
一.写在前面 有时候你的爬虫刚开始的时候可以正常运行,能够正常的爬取数据,但是过了一会,却出现了一个“403 Forbidden",或者是”您的IP访问频率太高“这样的提示,这就意味着你的I ...
- Workbench利用Python驱动DM执行Js进行建模
Workbench的工作平台下可以利用Python进行一些操作,包括添加system和component等等.DM可以通过执行Jscript脚本进行自动建模,因此,结合这两块的内容,可以利用Pytho ...
随机推荐
- Matlab学习笔记(2)
1. 在MATLAB中默认最开始出现的是命令窗口,也就是Command Window.对应的文件保存后扩展名一般都 是.mat 真正的程序代码编辑窗口应该新建New Script或者其他的.此时保存的 ...
- HTML-JS基础 变量与输入输出 运算符 分支结构
js中的变量 1.JS中变量声明的写法: var num=10;//使用var声明的变量属于局部变量只在当前作用域内有效 num=10;//不用var声明的变量,默认为全局变量,在整个JS文件中都有效 ...
- Web存储—简易注册登录
Web Storage是HTML5引入的一个非常重要的功能,可以在客户端本地存储数据,类似HTML4的cookie,但可实现功能要比cookie强大的多,cookie大小被限制在4KB,cookie只 ...
- Windows Graphics Programming Win32 GDI and DirectDraw第六章疑问
<Windows Graphics Programming Win32 GDI and DirectDraw>6.1节中有这样的描述: The Windows NT/2000 graphi ...
- 自写JS分页工具【基于JQ】
好久没有来逛园子,也好久没有更新博客,就像沉睡已久的人忽然被叫醒,忽然就被园友的回复惊醒了.园友提出了关于我之前一篇文章的疑问--可那已经是半年以前的博客了,加上我一直觉得分享给大家的应该是我最新的思 ...
- window.parent.document jquery
使用 jQuery ,写法如下: .$("#myEle", window.parent.document).html(html); 另外还有一种实现方式,代码如下: .parent ...
- mysql my.ini配置文件修改无效,修改mysql默认字符集
问题 开始于 使用mysql命令插入中文数据插不进去 ERROR 1366 (HY000): Incorrect string value: '\xD6\xD0\xCE\xC4' for column ...
- Ubuntu与Centos在登陆安全方面的比较
Ubuntu在安装时创建的普通用户默认具有sudo权限,默认root没有设置密码,可以通过自建用户来执行sudo passwd 为root设置密码;Centos在安装时创建的普通用户默认没有sudo权 ...
- vue-cli脚手架npm相关文件解读(6)build.js
系列文章传送门: 1.build/webpack.base.conf.js 2.build/webpack.prod.conf.js 3.build/webpack.dev.conf.js 4.bui ...
- [js高手之路]HTML标签解释成DOM节点
最近在封装一个开源框架,已经写了500行, 已经具备jquery的大多数常用功能.跟jquery的使用方法完全一样,jquery的选择器,几乎都能支持,为什么说这事,跟这篇文章的主题有毛关系呢?因为这 ...