<!DOCTYPE html>
<html lang="zh-Hans">
<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>小例子</title>
<style media="screen">
#box {
width: 100px;
height: 100px;
padding: 100px;
border: 4px solid red;
margin: 100px auto;
perspective: 300px;
}
#val {
width: 100px;
height: 100px;
position: relative;
transform-style: preserve-3d;
transition: 2s;
transform-origin: center center -50px;
}
#val div {
position: absolute;
width: 100px;
height: 100px;
background: red;
text-align: center;
font: 40px/100px "simhei";
}
#val div:nth-of-type(1) {
top: -100px;
background: #E4DE70;
transform-origin: bottom;
transform: rotateX(90deg);
}
#val div:nth-of-type(2) {
left: -100px;
background: #9D00A2;
transform-origin: right;
transform: rotateY(-90deg);
}
#val div:nth-of-type(3) {
background: #96EF24;
}
#val div:nth-of-type(4) {
left: 100px;
background: #3D006D;
transform-origin: left;
transform: rotateY(90deg);
}
#val div:nth-of-type(5) {
top: 100px;
background: #F40090;
transform-origin: top;
transform: rotateX(-90deg);
}
#val div:nth-of-type(6) {
background: #63E90D;
transform: translateZ(-100px);
}
#box:hover #val {
transform: rotateX(340deg) rotateY(190deg) rotateZ(220deg);
}
</style>
</head>
<body>
<div id="box">
<div id="val">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</div>
</body>
</html>
css3学习-3D变换小例子
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。