2021-6-10 前端達(dá)人
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
list-style: none;
}
html {
height: 100%;
}
.container {
width: 400px;
margin: 200px auto;
height: 100px;
position: relative;
}
.box {
width: 100px;
height: 100px;
position: absolute;
float: left;
}
#rigth {
background-color: rgba(0, 0, 0, 0.3);
position: absolute;
right: 0px;
top: 50%;
transform: translateY(-50%);
}
#left {
position: absolute;
left: 0px;
background-color: rgba(0, 0, 0, 0.3);
top: 50%;
transform: translateY(-50%);
}
span:hover {
cursor: pointer;
color: red;
}
ul {
width: 100px;
height: 100px;
transform-style: preserve-3d;
float: left;
transition: all 1s;
}
.top {
background-color: red;
transform: translateY(50px) rotateX(-90deg);
transform: translateY(50px) rotateX(-90deg);
background: url('./image/4.jpg') no-repeat;
}
.footer {
transform: translateY(-50px) rotateX(90deg);
background: url('./image/2.jpg') no-repeat;
}
.left {
transform: translateX(50px) rotateY(90deg)
}
.rigth {
background-color: yellow;
transform: translateX(-50px) rotateY(-90deg);
}
.Front {
background-color: pink;
transform: translateZ(50px);
background: url('./image/1.jpeg') no-repeat;
}
.behind {
background-color: blue;
transform: translateZ(-50px) rotateX(-180deg);
background: url('./image/3.jpg') no-repeat;
}
/* 前 */
.container ul:nth-child(2) .Front {
background-position: -100px 0;
}
.container ul:nth-child(3) .Front {
background-position: -200px 0;
}
.container ul:nth-child(4) .Front {
background-position: -300px 0;
}
/* 底部 */
.container ul:nth-child(2) .footer {
background-position: -100px 0;
}
.container ul:nth-child(3) .footer {
background-position: -200px 0;
}
.container ul:nth-child(4) .footer {
background-position: -300px 0;
}
/* 后面 */
.container ul:nth-child(2) .behind {
background-position: -100px 0;
}
.container ul:nth-child(3) .behind {
background-position: -200px 0;
}
.container ul:nth-child(4) .behind {
background-position: -300px 0;
}
/* 上面 */
.container ul:nth-child(2) .top {
background-position: -100px 0;
}
.container ul:nth-child(3) .top {
background-position: -200px 0;
}
.container ul:nth-child(4) .top {
background-position: -300px 0;
}
</style>
</head>
<body>
<div class="container">
<ul>
<li class="box top"></li>
<li class="box footer"></li>
<li class="box left"></li>
<li class="box rigth"></li>
<li class="box Front"></li>
<li class="box behind"></li>
</ul>
<ul>
<li class="box top"></li>
<li class="box footer"></li>
<li class="box left"></li>
<li class="box rigth"></li>
<li class="box Front"></li>
<li class="box behind"></li>
</ul>
<ul>
<li class="box top"></li>
<li class="box footer"></li>
<li class="box left"></li>
<li class="box rigth"></li>
<li class="box Front"></li>
<li class="box behind"></li>
</ul>
<ul>
<li class="box top"></li>
<li class="box footer"></li>
<li class="box left"></li>
<li class="box rigth"></li>
<li class="box Front"></li>
<li class="box behind"></li>
</ul>
<span id="rigth">下張</span>
<span href="JavaScript:;" id="left">上張</span>
</div>
</body>
<script>
var rigth = document.getElementById("rigth")
var left = document.getElementById("left")
var ul = document.querySelectorAll(".container ul")
var index = 0
var flags = false
rigth.onclick = function () {
if (flags == false) {
flags = true
index++
for (var i = 0; i < ul.length; i++) {
ul[i].style.transform = "rotateX(" + index * 90 + "deg)"
ul[i].style.transitionDelay = "" + i * 0.3 + "s"
}
setTimeout(function () {
flags = false
}, 2000)
}
}
left.onclick = function () {
if (flags == false) {
flags = true
index--
for (var i = 0; i < ul.length; i++) {
ul[i].style.transform = "rotateX(" + index * 90 + "deg)"
ul[i].style.transitionDelay = "" + i * 0.3 + "s"
}
setTimeout(function () {
flags = false
}, 2000)
}
}
</script>
</html>
作者:yuanzhuang
鏈接:https://www.jianshu.com/p/10c90c482795
來(lái)源:簡(jiǎn)書
藍(lán)藍(lán)設(shè)計(jì)建立了UI設(shè)計(jì)分享群,每天會(huì)分享國(guó)內(nèi)外的一些優(yōu)秀設(shè)計(jì),如果有興趣的話,可以進(jìn)入一起成長(zhǎng)學(xué)習(xí),請(qǐng)掃碼藍(lán)小助,報(bào)下信息,藍(lán)小助會(huì)請(qǐng)您入群。歡迎您加入噢~~希望得到建議咨詢、商務(wù)合作,也請(qǐng)與我們聯(lián)系。
藍(lán)藍(lán)設(shè)計(jì)( m.yvirxh.cn )是一家專注而深入的界面設(shè)計(jì)公司,為期望卓越的國(guó)內(nèi)外企業(yè)提供卓越的UI界面設(shè)計(jì)、BS界面設(shè)計(jì) 、 cs界面設(shè)計(jì) 、 ipad界面設(shè)計(jì) 、 包裝設(shè)計(jì) 、 圖標(biāo)定制 、 用戶體驗(yàn) 、交互設(shè)計(jì)、 網(wǎng)站建設(shè) 、平面設(shè)計(jì)服務(wù)
藍(lán)藍(lán)設(shè)計(jì)的小編 http://m.yvirxh.cn