IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> JavaScript知识库 -> JS-web旋转箱子 附源码 -> 正文阅读

[JavaScript知识库]JS-web旋转箱子 附源码

目录

????????

?效果图

?

?代码

????????

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>3D旋转盒子动画</title>

<meta name="viewport" content="width=device-width" />

<style type="text/css">

? ? [v-clock]{display: none}

? ? body {

? ? ? ? ?background-color: #1D1D1D;

? ? ? ? ?color:#fff;

? ? ? ? }

? ? .box {

? ? ? ? height: 400px;

? ? ? ? width: 400px;

? ? ? ? margin: 100px auto;

? ? ? ? position: relative;

? ? ? ? transform: rotateX(0deg) rotateY(0deg);

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

? ? ? ? cursor: move;

? ? }

? ?

? ? .box div {

? ? ? ? position: absolute;

? ? ? ? left: 0;

? ? ? ? right: 0;

? ? ? ? top: 100px;

? ? ? ? background-size: cover;

? ? ? ? background-position: center;

? ? }

? ? .picbtn{

? ? ? ? margin: ?0 auto;

? ? ? ? text-align: center;

? ? }

? ? body,input{font-family:sta cartman}

</style>

</head>

<body>

<div style="text-align:center;clear:both;">

<script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>

<script src="/follow.js" type="text/javascript"></script>

</div>

? ? <div id="app" v-cloak>

? ? ? ? <div class="box" :style="{width:size.x+'px',height:size.z+'px'}">

? ? ? ? ? ? <div id="top" :style="styleTop"></div>

? ? ? ? ? ? <div id="bottom" :style="styleBottom"></div>

? ? ? ? ? ? <div id="left" :style="styleLeft"></div>

? ? ? ? ? ? <div id="right" :style="styleRight"></div>

? ? ? ? ? ? <div id="pre" :style="stylePre"></div>

? ? ? ? ? ? <div id="back" :style="styleBack"></div>

? ? ? ? </div>

? ? </div>

<script src="jquery-1.11.3.min.js"></script>

<script src="vue.min.js"></script>

<script type="text/javascript">

? ? let x = '400', y = '400', z = '250';

? ? let vm = new Vue({

? ? ? ? el:'#app',

? ? ? ? data:{

? ? ? ? ? ? size:{

? ? ? ? ? ? ? ? x:x,

? ? ? ? ? ? ? ? y:y,

? ? ? ? ? ? ? ? z:z

? ? ? ? ? ? },

? ? ? ? ? ? styleLeft:{

? ? ? ? ? ? ? ? backgroundImage: `url(1.png)`,

? ? ? ? ? ? ? ? transform: '',

? ? ? ? ? ? ? ? width:'',

? ? ? ? ? ? ? ? height:''

? ? ? ? ? ? },

? ? ? ? ? ? styleRight:{

? ? ? ? ? ? ? ? backgroundImage: `url(2.png)`,

? ? ? ? ? ? ? ? transform: ``,

? ? ? ? ? ? ? ? width:'',

? ? ? ? ? ? ? ? height:''

? ? ? ? ? ? },

? ? ? ? ? ? styleTop:{

? ? ? ? ? ? ? ? backgroundImage: `url(3.png)`,

? ? ? ? ? ? ? ? transform: ``,

? ? ? ? ? ? ? ? width:'',

? ? ? ? ? ? ? ? height:''

? ? ? ? ? ? },

? ? ? ? ? ? styleBottom:{

? ? ? ? ? ? ? ? backgroundImage: `url(4.png)`,

? ? ? ? ? ? ? ? transform: ``,

? ? ? ? ? ? ? ? width:'',

? ? ? ? ? ? ? ? height:''

? ? ? ? ? ?

? ? ? ? ? ? },

? ? ? ? ? ? stylePre:{

? ? ? ? ? ? ? ? backgroundImage: `url(5.png)`,

? ? ? ? ? ? ? ? transform: ``,

? ? ? ? ? ? ? ? width:'',

? ? ? ? ? ? ? ? height:''

? ? ? ? ? ? },

? ? ? ? ? ? styleBack:{

? ? ? ? ? ? ? ? backgroundImage: `url(6.png)`,

? ? ? ? ? ? ? ? transform: ``,

? ? ? ? ? ? ? ? width:'',

? ? ? ? ? ? ? ? height:''

? ?

? ? ? ? ? ? }

? ? ? ? },

? ? ? ? computed:{

? ? ? ? ? ? preZ(){

? ? ? ? ? ? ? ? return Math.floor(this.size.y/2) + 'px'

? ? ? ? ? ? },

? ? ? ? ? ? backZ(){

? ? ? ? ? ? ? ? return Math.floor(this.size.y/2) + 'px'

? ? ? ? ? ? },

? ? ? ? ? ? leftZ(){

? ? ? ? ? ? ? ? return Math.floor(this.size.y/2) + 'px'

? ? ? ? ? ? },

? ? ? ? ? ? rightZ(){

? ? ? ? ? ? ? ? return Math.floor(this.size.x - this.size.y/2) + 'px'

? ? ? ? ? ? },

? ? ? ? ? ? topZ(){

? ? ? ? ? ? ? ? return Math.floor(this.size.y/2) + 'px'

? ? ? ? ? ? },

? ? ? ? ? ? bottomZ(){

? ? ? ? ? ? ? ? return Math.floor(this.size.z - this.size.y/2) + 'px'

? ? ? ? ? ? }

? ? ? ? },

? ? ? ? created(){

? ? ? ? ? ? this.creat()

? ? ? ? },

? ? ? ? watch:{

? ? ? ? ? ? size:{

? ? ? ? ? ? ? ? handler(){

? ? ? ? ? ? ? ? ? ? this.creat()

? ? ? ? ? ? ? ? },

? ? ? ? ? ? ? ? deep:true

? ? ? ? ? ? }

? ? ? ? },

? ? ? ? methods:{

? ? ? ? ? ? creat(){

? ? ? ? ? ? ? ? this.styleLeft.width = this.styleRight.width = this.size.y + 'px';

? ? ? ? ? ? ? ? this.styleLeft.height = this.styleRight.height = this.size.z + 'px';

? ? ? ? ? ? ? ? this.styleTop.width = this.styleBottom.width = this.size.x + 'px';

? ? ? ? ? ? ? ? this.styleTop.height = this.styleBottom.height = this.size.y + 'px';

? ? ? ? ? ? ? ? this.stylePre.width = this.styleBack.width = this.size.x + 'px';

? ? ? ? ? ? ? ? this.stylePre.height = this.styleBack.height = this.size.z + 'px';

? ? ? ? ? ? ? ? this.styleLeft.transform = `rotateY(-90deg) translateZ(${this.leftZ})`;

? ? ? ? ? ? ? ? this.styleRight.transform = `rotateY(90deg) translateZ(${this.rightZ})`;

? ? ? ? ? ? ? ? this.styleTop.transform = `rotateX(90deg) translateZ(${this.topZ})`;

? ? ? ? ? ? ? ? this.styleBottom.transform = `rotateX(-90deg) translateZ(${this.bottomZ})`;

? ? ? ? ? ? ? ? this.stylePre.transform = `translateZ(${this.preZ})`;

? ? ? ? ? ? ? ? this.styleBack.transform = `rotateY(180deg) translateZ(${this.backZ})`;

? ? ? ? ? ? },

? ? ? ? }

? ? })


?

</script>

<script src="jquery-touchrotate.js"></script>

<script type="text/javascript">

? ? $('.box').touchrotate({

? ? ? ? //初始3D旋转

? ? ? ? rotateX: -10,

? ? ? ? rotateY: 10,

? ? ? ? //数值越小 , 旋转速度越快

? ? ? ? speedX: 2,

? ? ? ? speedY: 2,

? ? ? ? // 旋转的倍数, 越大旋转的圈数越多

? ? ? ? multipleX: 50,

? ? ? ? multipleY: 50,

? ? ? ? // 动画持续的时间, 单位是S

? ? ? ? time: 2,

? ? ? ? //模式 0:表示匀速运动 , 运动中途可以重新开始 , 1表示先加速后减速(动画过程中不可滑动,体验效果差)

? ? ? ? model: 0

? ? });

</script>


?

</body>

</html>

?

?

  JavaScript知识库 最新文章
ES6的相关知识点
react 函数式组件 & react其他一些总结
Vue基础超详细
前端JS也可以连点成线(Vue中运用 AntVG6)
Vue事件处理的基本使用
Vue后台项目的记录 (一)
前后端分离vue跨域,devServer配置proxy代理
TypeScript
初识vuex
vue项目安装包指令收集
上一篇文章      下一篇文章      查看所有文章
加:2021-10-29 12:54:58  更:2021-10-29 12:55:51 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/10 7:34:44-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码