当前位置:首页 >> 网络编程

jQuery实现可拖拽3D万花筒旋转特效

这是一个使用了CSS3立体效果的强大特效,本特效使用jQuery跟CSS3 transform来实现在用户鼠标按下拖动时,环形图片墙可以跟随鼠标进行3D旋转动画。

进去后可以上下左右的拖动图片。

本示例中使用到了CSS3的transform-style 属性,该规定如何在 3D 空间中呈现被嵌套的元素。

默认值: flat

继承性: no

版本: CSS3

JavaScript 语法: object.style.transformStyle="preserve-3d"

有2个属性值可选择:

flat 子元素将不保留其 3D 位置。

preserve-3d 子元素将保留其 3D 位置。

示例代码如下:

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery可拖拽3D万花筒旋转特效 - 何问起</title><base target="_blank" />
<style type="text/css">
 *{margin:0;padding: 0;}
 .hovertree{
 width: 120px;
 height: 180px;
 margin: 150px auto 0;
 position: relative;
 /*transform 旋转元素*/
 transform-style:preserve-3d;
 transform:perspective(800px) rotateX(-10deg) rotateY(0deg);
 }
 body{background-color: #66677c;}
 .hovertree img{
 position: absolute;
 width: 100%;
 height: 100%;
 border-radius: 5px;
 box-shadow: 0px 0px 10px #fff;
 /*倒影的设置*/
 -webkit-box-reflect:below 10px -webkit-linear-gradient(top,rgba(0,0,0,0) 50%,rgba(0,0,0,.5) 100%);
 }
 .hovertree p{
 width: 1200px;
 height: 1200px;
 background: -webkit-radial-gradient(center center,600px 600px,rgba(255,255,255,.5),rgba(0,0,0,0));
 position: absolute;
 top:100%;left:50%;
 margin-top: -600px;
 margin-left: -600px;
 border-radius:600px;
 transform:rotateX(90deg);
 }
 .hewenqi{position:absolute;z-index:99;}
 a{color:blue;}
</style>
</head>
<body>
<div class="hovertree">
 <img src="/UploadFiles/2021-04-02/01.jpg">

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