html5移动特效,html5立体效果

HTML5实现图片拖动,旋转,放大,拉伸等特效后保存效果

可以设置cookie(可以加载一个cookie.min.js,使用起来非常方便)。就是当第一次进入页面的时候,先去读取该cookie,如果存在,说明之前已经做了更改,把cookie值稍作处理就可以完成初始化了(记得当初始化完成后删除该cookie),如果cookie不存在说明还没有做过更改。

目前创新互联已为近千家的企业提供了网站建设、域名、虚拟空间、网站托管维护、企业网站设计、水磨沟网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

html5上下滑动“翻页”实现,是真正的翻页

HTML5手机上下滑动翻页特效是一款手机移动端触屏滑动效果实现完整代码如下:

1、html5页面代码

!DOCTYPE html

htmlheadmeta http-equiv="Content-Type" content="text/html; charset=UTF-8"

titleHTML5手机页面触屏滑动上下翻页特效/title

meta charset="utf-8"

meta name="apple-touch-fullscreen" content="YES"

meta name="format-detection" content="telephone=no"

meta name="apple-mobile-web-app-capable" content="yes"

meta name="apple-mobile-web-app-status-bar-style" content="black"

meta http-equiv="Expires" content="-1"

meta http-equiv="pragram" content="no-cache"

link rel="stylesheet" type="text/css" href="./hamer_files/main.css"

link rel="stylesheet" type="text/css" href="./hamer_files/endpic.css"

script type="text/javascript" src="./hamer_files/offline.js"/script

meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi"

/head

body class="s-bg-ddd pc no-3d perspective yes-3d" style="-webkit-user-select: none;"

section class="u-alert"

  img style="display:none;" src="./hamer_files/loading_large.gif"

  div class="alert-loading z-move"

      div class="cycleWrap" span class="cycle cycle-1"/span

          span class="cycle cycle-2"/spanspan class="cycle cycle-3"/spanspan class="cycle cycle-4"/span

      /div

      div class="lineWrap" span class="line line-1"/spanspan class="line line-2"/spanspan class="line line-3"/span

      /div

  /div

/section

section class="u-arrow"

  p class="css_sprite01"/p

/section

section class="p-ct transformNode-2d transformNode-3d" style="height: 918px;"

  div class="translate-back" style="height: 918px;"

      div class="m-page m-fengye" data-page-type="info_pic3" data-statics="info_pic3" style="height: 918px;"

          div class="page-con lazy-finish" data-position="50% 50%" data-size="cover" style="height: 920px; background-image: url(hamer_files/1.jpg); background-size: cover; background-position: 50% 50%;"/div

      /div

      div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px;"

          div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/2.jpg); background-size: cover; background-position: 50% 50%;"/div

      /div

      div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px;"

          div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/3.jpg); background-size: cover; background-position: 50% 50%;"/div

      /div

      div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px;"

          div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/4.jpg); background-size: cover; background-position: 50% 50%;"/div

      /div

      div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px;"

          div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/5.jpg); background-size: cover; background-position: 50% 50%;"/div

      /div

      div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px;"

          div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/6.jpg); background-size: cover; background-position: 50% 50%;"/div

      /div

      div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px;"

          div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/7.jpg); background-size: cover; background-position: 50% 50%;"/div

      /div

      div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px;"

          div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/8.jpg); background-size: cover; background-position: 50% 50%;"/div

      /div

  /div

/section

section class="u-pageLoading"

  img src="./hamer_files/load.gif" alt="loading"

/section

script src="./hamer_files/init.mix.js" type="text/javascript" charset="utf-8"/script

script src="./hamer_files/coffee.js" type="text/javascript" charset="utf-8"/script

script src="./hamer_files/99_main.js" type="text/javascript" charset="utf-8"/script

/body/html

2、css代码:

@charset "utf-8";

.ad_foot li { margin:0 auto 1em; font-size:1.8em; padding:15px; background:#FFF;}

.ad_foot li a {display:block;}

.ad_foot li .l {width:75px; height:75px; float:left; overflow:hidden;}

.ad_foot li .l img {width:75px; width:75px;}

.ad_foot li .r {width:78%; float:left; margin-left:30px; color:#666; overflow:hidden;}

.ad_foot li .r p {color:#999; font-size:1.2em; }

.ad_foot li .r span {font-size:0.8em;}

.ad_foot li .r i {font-style:normal;}

.lazy-img, .lazy-finish{background-color:#f0eded;}

.page-list{font-size:20px;font-family: "Microsoft yahei";padding-left:17px;padding-top:30px;height:35px;border-bottom:1px solid #b5b5b5;display:none;}

.ad_foot{padding:15px 15px 0 15px;}

/*声音播放按钮*/

#song_img {width:293px; height:41px; display:block; position:absolute; right:4.1em; top:1.6em; font-size:1.7em; text-align:center; line-height:41px; color:#FFF; background:url(../img/music_c3.png) no-repeat 0 0;}

/*底部推荐*/

.ad_list{margin-top:2em;}.ad_list li {width:46%; background:none; padding:0; float:left;margin-bottom: 1em;}

.ad_list li.r {float:right;}.ad_list li a img {width:100%; height:auto;}

.ad_foot h3 {width:100%; height:48px; line-height:48px; background:#F9F5EC;}

.ad_foot h3 a {display:inline-block; color:#444; width:50%; text-align:center; font-size:1.5em; height:48px; border-bottom:2px solid #FF9240;}

.ad_foot h3 a.active {color:#FFF; background:#FF9240;}

.magazine_1 li {

width:100%;

margin-bottom: 1em;

font-size: 1.8em;

padding: 15px;

background: #FFF;}

.magazine_1 li a {display:block;}

.magazine_1 li .l {width: 75px;

height: 75px;

float: left;

overflow: hidden;}

.magazine_1 li .l img {width:75px; height:75px;}

.magazine_1 li .r {width: 78%;

float: left;

margin-left: 30px;

color: #666;

overflow: hidden;}

.magazine_1 li .r p {

color: #999;

font-size: 1.2em;

.magazine_1 li .r span {font-size:0.8em;}

.ad_foot li .r i {font-style:normal;}

3、运行效果如下:

HTML5动画特效怎么做

主要思想:

首先要准备一张有连续帧的图片,然后利用HTML5 Canvas的draw方法在不同的时间间隔绘制不同的帧,这样看起来就像动画在播放。

关键技术点:

JavaScript 函数setTimeout()有两个参数,第一个是参数可以传递一个JavaScript方法,

另外一个参数代表间隔时间,单位为毫秒数。代码示例:

setTimeout( update, 1000/30);

Canvas的API-drawImage()方法,需要指定全部9个参数:

ctx.drawImage(myImage, offw, offh, width,height, x2, y2, width, height);

其中offw, offh是指源图像的起始坐标点,width, height表示源图像的宽与高,x2,y2表

示源图像在目标Canvas上的起始坐标点。

!DOCTYPE html 

html 

head 

meta http-equiv="X-UA-Compatible" content="chrome=IE8" 

meta http-equiv="Content-type" content="text/html;charset=UTF-8" 

titleCanvas Mouse Event Demo/title 

link href="default.css" rel="stylesheet" / 

script 

var ctx = null; // global variable 2d context 

var started = false; 

var mText_canvas = null; 

var x = 0, y =0; 

var frame = 0; // 22 5*5 + 2 

var imageReady = false; 

var myImage = null; 

var px = 300; 

var py = 300; 

var x2 = 300; 

var y2 = 0; 

window.onload = function() { 

var canvas = document.getElementById("animation_canvas"); 

console.log(canvas.parentNode.clientWidth); 

canvas.width = canvas.parentNode.clientWidth; 

canvas.height = canvas.parentNode.clientHeight; 

if (!canvas.getContext) { 

console.log("Canvas not supported. Please install a HTML5 compatible browser."); 

return; 

// get 2D context of canvas and draw rectangel 

ctx = canvas.getContext("2d"); 

ctx.fillStyle="black"; 

ctx.fillRect(0, 0, canvas.width, canvas.height); 

myImage = document.createElement('img'); 

myImage.src = "../robin.png"; 

myImage.onload = loaded(); 

function loaded() { 

imageReady = true; 

setTimeout( update, 1000/30); 

function redraw() { 

ctx.clearRect(0, 0, 460, 460) 

ctx.fillStyle="black"; 

ctx.fillRect(0, 0, 460, 460); 

// find the index of frames in image 

var height = myImage.naturalHeight/5; 

var width = myImage.naturalWidth/5; 

var row = Math.floor(frame / 5); 

var col = frame - row * 5; 

var offw = col * width; 

var offh = row * height; 

// first robin 

px = px - 5; 

py = py - 5; 

if(px  -50) { 

px = 300; 

if(py  -50) { 

py = 300; 

//var rate = (frame+1) /22; 

//var rw = Math.floor(rate * width); 

//var rh = Math.floor(rate * height); 

ctx.drawImage(myImage, offw, offh, width, height, px, py, width, height); 

// second robin 

x2 = x2 - 5; 

y2 = y2 + 5; 

if(x2  -50) { 

x2 = 300; 

y2 = 0; 

ctx.drawImage(myImage, offw, offh, width, height, x2, y2, width, height); 

function update() { 

redraw(); 

frame++; 

if (frame = 22) frame = 0; 

setTimeout( update, 1000/30); 

/script 

/head 

body 

h1HTML Canvas Animations Demo - By Gloomy Fish/h1 

prePlay Animations/pre 

div id="my_painter" 

canvas id="animation_canvas"/canvas 

/div 

/body 

/html

怎样通过HTML5让移动APP页面有动效?(三)

5.背景音乐音效

H5页面要炫酷,画面生动还是不够的,一定要配合生动的音乐。因此可以主动跟设计或产品沟通,让他们可以提供音乐资源,分分钟导致UV猛涨有木有!当然,有了音乐,前端也不是直接引用的,还是有点要求:

1.音乐不宜过长,30s为佳,而且音乐要加上渐现渐隐效果,方便循环播放;

2.音乐体积要小,音质和流量,在手机上还是优先考虑流量吧。

一般背景音乐体积可以接受的范围是200K以下,若太大,可以使用格式工厂等软件,降低它的比特率和声道来改变体积。接着,只需要简单引用。这里有个问题,IOS是不能自动播放音乐的,一定要触发一个用户交互事件,例如点击。

但是有一种hack的方法可以让IOS微信侧页面自动播放(SAFARI依旧无效):通过new一张图片,监听一张图片的onload事件,结束后回调执行音频播放audio.play()即可,原理估计是动了dom结构,相当于执行了一次交互。(有人也用过createEvent模拟,原理也是动了dom。)因此,记得暴露一个音乐关闭/打开的按钮,不然肯定被用户骂死。

6.有趣的loading

Loading页还是要有的,万一用户网速慢呢?以上做了那么多事,如果没有资源加载都是玩不来的,因此还需要一个loading的支持。一般情况下页面体积大于3m则要加上loading页。然而loading还是可以做得很有趣的,一般的做法是:

1.引入品牌,例如APP宣传页;

2.引入有趣动画,放一个贱贱的人物跳舞给你看;

3.一切从简,用CSS3简单动画。

当然,真正要做到高效制作动态H5页面,还是靠积累,因此平时做好的细节动画自己都积累起来,下次分分钟就能用得上。

20.【Web API】——移动端网页特效(2020-09-13)

1.touchstart、touchmove、touchend可以实现拖动元素2.但是拖动元素需要当前手指的坐标值我们可以使用targetTouchest[0]里面的pageX和pageY

3.移动端拖动的原理:手指移动中,计算出手指移动的距离。然后用盒子原来的位置+手指移动的距离

4.手指移动的距离:手指滑动中的位置减去手指刚开始触摸的位置拖动元素三步曲:

(1)触摸元素touchstart:获取手指初始坐标,同时获得盒子原来的位置

(2)移动手指touchmove:计算手播的滑动距离,并且移动盒子

(3)离开手指touchend:

注意:手指移动也会触发滚动屏幕所以这里要阻止默认的屏幕滚动e.preventDefault();

1.常用插件

(1)fastclick解决300ms延迟

(2)Swipper

(3)superslide

(4)iscroll

(5)zy.media.js视频插件

2.插件使用

(1)引入js插件文件;

(2)按照规定语法使用;

classList属性是HTML5新增的一个属性,返回元素的类名,但是ie10以上版本支持。

该属性用于在元素中添加,移除及切换CSS类。有以下方法

移动端click事件会有300ms的延时,原因是移动端屏幕双击会缩放(double tap to zoom)页面。

解决方案:

(1)禁用缩放,浏览器禁用默认的双击缩放行为并且去掉300ms的点击延迟;

(2)利用touch事件自己封装这个事件解决300ms延迟。

原理就是:

1.当我们手指触摸屏幕,记录当前触摸时间

2.当我们手指离开屏幕,用离开的时间减去触摸的时间

3.如果时间小于150ms,并且没有滑动过屏幕,那么我们就定义为点击

(3)使用插件。fastclick 插件解决300ms延迟

框架,顾名思义就是一套架构,它会基于自身的特点向用户提供套较为完整的解决方案。框架的控制权在框架本身,使用者要按照框架所规定的某种规范进行开发。

前端常用的框架有Bootstrap、Vue、Angular等。

Bootstrap是一个简洁、直观、强保的前端开发框架,它让web 开发更迅速、简单。

它能开发PC端,也能开发移动端

BootstrapJS插件使用步骤:

1.引入相关s文件

2.复制HTML结构

3.修改对应样式

4.修改相应JS参数

MUI是一个专门用于做手机APP的前端框架。

MUI的UI设计理念是:以IOS为基础,补充Android平台特有的控件。因此MUI封装的控件,UI上更符合app的体验。

html5版本水平移动效果怎么实现

 对 SVG 图进行缩放和平移的最简单方法是使用浏览器自带的缩放和滚动功能。在 Internet Explorer 9 中,下表描述了与缩放相关的鼠标和键盘快捷方式。 用户操作 键盘快捷键 鼠标快捷键 放...


分享名称:html5移动特效,html5立体效果
文章分享:http://ybzwz.com/article/dsecjed.html