时钟效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
/* .sec-wrapper{
width: 500px;
height: 500px;
animation: run 60s;
}
/*转的不是秒针本身,是秒针的容器,设置秒针本身转动,其中心点会在秒针的中间位置自我旋转*/
/* .sec{
height: 250px;
width: 4px;
background-color: red;
margin: 0 auto;
} */
/*设置表样式*/
.clock{
width: 500px;
height: 500px;
margin: 0 auto;
margin-top: 100px;
border-radius: 50%;
position: relative;
background-image: url(./img/1.png);
background-size: cover;
}
/*让所有clock下面的元素都设置其样式*/
.clock > div{
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
}
/*设置时针*/
.hour-wrapper{
height: 40%;
width: 60%;
animation: run 3200s linear infinites;
}
.hour{
height: 50%;
width: 6px;
background-color: black;
margin: 0 auto
}
.min-wrapper{
height: 50%;
width: 50%;
animation: run 120s steps(60) infinite;
}
.min{
height: 50%;
width: 4px;
background-color: black;
margin: 0 auto
}
.sec-wrapper{
height: 95%;
width: 95%;
animation: run 60s infinite;
}
.sec{
height: 50%;
width: 2px;
background-color: rgb(222, 29, 29);
margin: 0 auto
}
@keyframes run{
from{
transform: rotateZ(0);
}
to{
transform: rotateZ(360deg);
}
}
</style>
</head>
<body>
<!-- <div class="sec-wrapper">
<div class="sec"></div>
</div> -->
<div class="clock">
<!--创建时针-->
<div class="hour-wrapper">
<div class="hour"></div>
</div>
<div class="min-wrapper">
<div class="min"></div>
</div>
<div class="sec-wrapper">
<div class="sec"></div>
</div>
</div>
</body>
</html>
时钟效果
3D魔方效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html{
perspective: 800px;
}
.cube{
width: 400px;
height: 400px;
/* background-color: #bfa; */
margin: 100px auto;
/*显示3d效果*/
transform-style: preserve-3d;
/* transform: rotateX(45deg) rotateZ(45deg); */
/*设置转动的效果*/
animation: rotate 10s infinite linear;
}
.cube > div{
width: 400px;
height: 400px;
/*设置元素透明效果*/
opacity: 0.7;
position: absolute;
}
/*设置图片位置偏上挤,消除空隙*/
img{
vertical-align: top;
}
.box1{
transform:rotateY(90deg) translateZ(200px);
}
.box2{
transform:rotateY(-90deg) translateZ(200px);
}
.box3{
transform:rotateX(90deg) translateZ(200px) ;
}
.box4{
transform:rotateX(-90deg) translateZ(200px) ;
}
.box5{
transform:rotateY(180deg) translateZ(200px) ;
}
.box6{
transform:rotateY(0deg) translateZ(200px) ;
}
@keyframes rotate {
from{
transform: rotateX(0) rotateZ(0);
}
/*让其沿着x和y轴转一圈*/
to{
transform: rotateX(1turn) rotateZ(1turn) ;
}
}
</style>
</head>
<body>
<!--创建一个外部容器-->
<div class="cube">
<div class="box1">
<img src="./img/2.jpg" alt="">
</div>
<div class="box2" >
<img src="./img/2.jpg" alt="">
</div>
<div class="box3" >
<img src="./img/2.jpg" alt="">
</div>
<div class="box4" >
<img src="./img/2.jpg" alt="">
</div>
<div class="box5" >
<img src="./img/2.jpg" alt="">
</div>
<div class="box6" >
<img src="./img/2.jpg" alt="">
</div>
</div>
</body>
</html>
魔方练习