网站点击数字翻页html代码,JavaScript中transform实现数字翻页效果

本文介绍了一种使用CSS3实现的3D翻页效果,通过设置不同的旋转角度来模拟纸张翻页的过程,并提供了完整的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

效果图:

0b50bfb3969c9acc9435958a2d43d7ad.png

图(1)初始图

fbe72274a566e1c831c1e02555b8f033.png

图(2)翻页过程

e246597c7304f14da474ae6178997b42.png

图(3)翻页结果

代码如下:

transition

#container{ width:500px; height:500px; margin:20px auto; background:#ff0000;

-webkit-transiton:background 2s linear,width 2s,height 2s;

-moz-transition:background 2s,width 2s,height 2s;

-o-transition:background 2s,width 2s,height 2s;

-ms-transition:background 2s,width 2s,height 2s;

transition:background 2s,width 2s,height 2s;

}

#container:hover{ background: #00ff00;width:200px;height: 200px;}

#my3dspace{

-webkit-perspective:800;

-webkit-perspective-origin:50% 50%;

overflow: hidden;

}

#pagegroup{

width: 400px;

height: 400px;

margin: 0 auto;

-webkit-transform-style:preserve-3d;

position: relative;

}

.page{

width: 360px;

height: 360px;

padding: 20px;

background-color: black;

color: white;

font-size: 360px;

font-weight: blod;

line-height: 360px;

text-align: center;

position: absolute;

}

#page1{

-webkit-transform-origin:top;

transform-origin:top;

-webkit-transition:-webkit-transform 1s linear;

transition:transform 1s linear;

}

#page2,#page3,#page4,#page5,#page6{

-webkit-transform-origin:top;

transform-origin:top;

-webkit-transition:-webkit-transform 1s linear;

transition:transform 1s linear;

-webkit-transform:rotateX(-90deg);

transform:rotateX(-90deg);

}

#op{

text-align: center;

margin: 40px auto;

}

1
2
3
4
5
6

next 

prev

var curIndex = 1;

function next(){

if(curIndex==6)

return;

var curPage = document.getElementById("page"+curIndex);

curPage.style.webkitTransform = "rotateX(90deg)";

curPage.style.transform = "rotateX(90deg)";

curIndex ++;

var nextPage = document.getElementById("page"+curIndex);

nextPage.style.webkitTransform="rotateX(0deg)";

nextPage.style.transform="rotateX(0deg)";

}

function prev(){

if(curIndex==1)

return;

var curPage =document.getElementById("page"+curIndex);

curPage.style.webkitTransform="rotateX(-90deg)";

curPage.style.transform="rotateX(-90deg)";

curIndex --;

var prevPage = document.getElementById("page"+curIndex);

prevPage.style.webkitTransform="rotateX(0deg)";

prevPage.style.transform="rotateX(0deg)";

}

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持脚本之家!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值