01手风琴
<style>
* {
margin: 0px;
padding: 0px;
}
ul,
li {
list-style: none;
}
body {
background-color: #efefef;
}
.content {
padding: 20px;
width: 800px;
height: 125px;
/* box-sizing: border-box; */
border-radius: 10px;
margin: 100px auto 0px;
background-color: white;
overflow: hidden;
}
.content ul {
width: 120%;
height: 100%;
}
.content ul li {
/* (800-50)/6 */
width: 125px;
height: 125px;
border-radius: 10px;
overflow: hidden;
float: left;
margin-right: 10px;
/* 过渡 */
transition: all 1s;
}
.content ul li:last-child {
margin-right: 0px;
}
.content ul li img {
width: 575px;
height: 100%;
}
.content:hover li {
width: 35px;
}
.content ul li:hover {
width: 575px;
}
</style>
</head>
<body>
<div class="content">
<ul>
<li>
<img src="../images/1.jpg" alt="">
</li>
<li>
<img src="../images/2.jpg" alt="">
</li>
<li>
<img src="../images/3.png" alt="">
</li>
<li>
<img src="../images/4.jpg" alt="">
</li>
<li>
<img src="../images/5.jpg" alt="">
</li>
<li>
<img src="../images/6.jpg" alt="">
</li>
</ul>
</div>
</body>
02小米商城
<style>
body {
background-color: #f5f5f5;
}
.content {
width: 234px;
height: 300px;
text-align: center;
background-color: #fff;
margin: 100px auto;
/* /过渡 */
transition: all 1s;
}
.content:hover {
transform: translate(0px, -5px);
box-shadow: 3px 10px 16px 0px #ccc;
}
.content img {
width: 160px;
height: 160px;
}
</style>
</head>
<body>
<div class="content">
<img src="https://cdn.cnbj1.fds.api.mi-img.com/nr-pub/202308081914_12255c6dc58e78e32afe9665b13fbaaa.png?thumb=1&w=200&h=200&f=webp&q=90"
alt="">
</div>
</body>
03风车
<style>
* {
margin: 0px;
padding: 0px;
}
.content {
width: 405px;
height: 400px;
margin: 100px auto;
transition: all 30s;
}
.rod {
position: absolute;
width: 20px;
height: 465px;
border-radius: 10px;
background-image: linear-gradient(to right bottom, #FF7F50, #FFD700);
left: 50%;
transform: translate(-63%, 193px);
z-index: -1;
}
.content .top div,
.content .bottom div {
float: left;
}
.content .top {
width: 100%;
height: 200px;
}
.content .bottom .right,
.content .top .left {
width: 200px;
height: 200px;
/* 渐变色 */
background-image: linear-gradient(to right bottom, skyblue, pink);
/* border-radius: 左上角 右上角 右下角 左下角; */
border-radius: 0px 200px 0px 200px;
}
.content .bottom .left,
.content .top .right {
width: 200px;
height: 200px;
/* 渐变色 */
background-image: linear-gradient(to right top, skyblue, pink);
/* border-radius: 左上角 右上角 右下角 左下角; */
border-radius: 200px 0px 200px 0px;
}
.content .top .right {
background-image: linear-gradient(to right bottom, #A0522D, #F0E68C);
}
.content .bottom .left {
background-image: linear-gradient(to right top, aqua, springgreen);
}
.content .bottom .right {
background-image: linear-gradient(to right top, #FF4500, #C71585);
}
.content:hover {
transform: rotate(3600deg);
}
</style>
</head>
<body>
<div class="rod"></div>
<div class="content">
<div class="top">
<div class="left"></div>
<div class="right"></div>
</div>
<div class="bottom">
<div class="left"></div>
<div class="right"></div>
</div>
</div>
</body>
04-3d旋转
<style>
body {
/* 透视 */
perspective: 1000px;
}
.box {
width: 400px;
height: 600px;
/* background-color: red; */
margin: 100px auto;
background-image: url(../images/liu.jpg);
background-size: cover;
background-repeat: no-repeat;
transition: all 3s;
/* 背部可见性 */
backface-visibility: hidden;
}
.box:hover {
/* transform: rotateX(180deg); */
transform: rotateY(180deg);
/* transform: rotateZ(180deg); */
}
</style>
</head>
<body>
<div class="box"></div>
</body>
05开门案例
<style>
/* 透视 */
body {
perspective: 1000px;
}
.content {
width: 500px;
height: 400px;
border: 1px solid red;
margin: 100px auto;
/* 透视 父元素 */
perspective: 1000px;
position: relative;
background-image: url(https://img0.baidu.com/it/u=1856123620,3576811447&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=333);
background-repeat: no-repeat;
background-size: 100% 100%;
}
.content div {
width: 50%;
/* float: left; */
height: 100%;
background-image: url(../images/bg.png);
transition: all 1s;
position: absolute;
}
.content .left {
top: 0px;
left: 0px;
/* 修改变形原点 */
transform-origin: left center;
}
.content .right {
top: 0px;
right: 0px;
/* 修改变形原点 */
transform-origin: right center;
}
.content:hover .left {
transform: rotateY(-100deg);
}
.content:hover .right {
transform: rotateY(100deg);
}
</style>
</head>
<body>
<div class="content">
<!-- <h1>开门大吉</h1> -->
<div class="left"></div>
<div class="right"></div>
</div>
</body>
06-3d魔方
<style>
body {
/* 透视 */
perspective: 1000px;
}
.content {
width: 300px;
height: 300px;
/* border: 1px solid red; */
margin: 280px auto 0px;
transform: rotateX(-30deg) rotateY(30deg);
/* 保留3d效果 */
transform-style: preserve-3d;
transition: all 50s;
}
.content:hover {
transform: rotateX(-3000deg) rotateY(3000deg);
}
.content .view {
width: 300px;
height: 300px;
position: relative;
/* 保留3d效果 */
transform-style: preserve-3d;
}
.content .view div {
width: 300px;
height: 300px;
position: absolute;
text-align: center;
line-height: 300px;
color: white;
font-size: 28px;
transition: all 1s;
}
.content .view div:nth-child(1) {
background-color: pink;
transform: translateZ(150px);
}
.content .view div:nth-child(2) {
background-color: skyblue;
transform: rotateX(90deg) translateZ(150px);
}
.content .view div:nth-child(3) {
background-color: purple;
transform: rotateY(-90deg) translateZ(150px);
}
.content .view div:nth-child(4) {
background-color: orange;
transform: rotateY(90deg) translateZ(150px);
}
.content .view div:nth-child(5) {
background-color: aqua;
transform: rotateY(180deg) translateZ(150px);
}
.content .view div:nth-child(6) {
background-color: springgreen;
transform: rotateX(-90deg) translateZ(150px);
}
.content .view:hover div:nth-child(1) {
transform: translateZ(200px);
}
.content .view:hover div:nth-child(2) {
transform: rotateX(90deg) translateZ(200px);
}
.content .view:hover div:nth-child(3) {
transform: rotateY(-90deg) translateZ(200px);
}
.content .view:hover div:nth-child(4) {
transform: rotateY(90deg) translateZ(200px);
}
.content .view:hover div:nth-child(5) {
transform: rotateY(180deg) translateZ(200px);
}
.content .view:hover div:nth-child(6) {
transform: rotateX(-90deg) translateZ(200px);
}
</style>
</head>
<body>
<div class="content">
<div class="view">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</div>
</body>
07大商创案例
<style>
.box {
width: 300px;
height: 300px;
background-color: red;
margin: 100px auto;
/* 起始位置 */
transform: rotateZ(30deg);
/* 改变变形原点 */
transform-origin: right bottom;
/* 透明 */
opacity: 0;
/* 应用动画 */
animation: boxmove 2s ease 1;
/* 动画之外的状态 */
/* backwards 动画完成之后停留在第一帧 */
/* forwards 动画完成之后停留在最后一帧 */
animation-fill-mode: forwards;
}
/* 创建自定义动画 */
@keyframes boxmove {
form {
transform: rotateZ(30deg);
opacity: 0;
}
to {
transform: rotateZ(0deg);
opacity: 1;
}
}
</style>
</head>
<body>
<div class="box"></div>
</body>
08自行车案例
<style>
img{
width: 120px;
height: 158px;
/* 动画简写 */
animation: carMove 5s linear 1;
}
@keyframes carMove{
0%{
transform: translateX(0px);
}
25%{
transform: translateX(800px);
}
50%{
transform: translateX(800px) rotateY(180deg);
}
75%{
transform: translateX(0px) rotateY(180deg);
}
100%{
transform: translateX(0px) rotateY(0deg);
}
}
</style>
</head>
<body>
<img src="../images/car.jpg" alt="">
</body>
09充电小球
<style>
body {
background-color: #8B4513;
}
.circle {
width: 150px;
height: 150px;
border-radius: 50%;
background-color: #00FA9A;
margin: 200px auto;
box-shadow: 0px 0px 20px 5px #00FA9A;
overflow: hidden;
text-align: center;
position: relative;
}
.circle span {
z-index: 2;
position: absolute;
top: 34%;
left: 9px;
}
.circle::after {
content: "";
display: block;
width: 300px;
height: 300px;
border-radius: 120px;
background-color: white;
position: absolute;
top: -142px;
left: -100px;
/* 应用动画 */
animation: circleMove 10s linear 1 forwards;
}
@keyframes circleMove {
from {
transform: translateY(0px) rotate(0deg);
}
to {
transform: translateY(-168px) rotate(1000deg);
}
}
</style>
</head>
<body>
<div class="circle">
<span class="txt">当前电量: 0%</span>
</div>
<script>
//
var txt = document.querySelector(".txt");
var num = 0;
var timerid = setInterval(function () {
num += 0.1
if (num >= 100) {
clearInterval(timerid)
} else {
txt.innerHTML = "当前电量:" + num.toFixed(2) + "%";
}
}, 10)
</script>
</body>