更新第43个小实例

This commit is contained in:
DESKTOP-BM6RJU5\wyanh 2021-11-15 16:50:10 +08:00
parent d2c522e73f
commit 7ae5c8736a
3 changed files with 108 additions and 1 deletions

View File

@ -46,4 +46,5 @@
39. HTML5+CSS3小实例之手机充电特效
40. HTML5+CSS3小实例之抽屉式相册
41. HTML5+CSS3小实例之发光文字悬停特效
42. HTML5+CSS3小实例之背景不停渐变效果
42. HTML5+CSS3小实例之背景不停渐变效果
43. HTML5+CSS3小实例之3D轮播卡片

78
css/43.css Normal file
View File

@ -0,0 +1,78 @@
*{
/* 初始化 取消内外边距 */
margin: 0;
padding: 0;
}
body{
/* 100%窗口高度 */
height: 100vh;
/* 弹性布局 水平垂直居中 */
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
background-color: #000;
}
.container{
width: 300px;
height: 450px;
/* 这个属性用来增加卡片旋转的立体感 */
perspective: 1000px;
/* 相对定位 */
position: relative;
}
.card-box{
/* 绝对定位 */
position: absolute;
width: 100%;
height: 100%;
/* 给父元素加一个3D盒子属性 */
transform-style: preserve-3d;
transform: rotateY(0) translateZ(-700px);
/* 执行动画:动画名 时长 贝塞尔曲线 无限次播放 */
animation: cardRotate 10s cubic-bezier(0.77,0,0.175,1) infinite;
}
.card{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
/* 设置元素的倒影效果below是倒影在元素下方15px是元素和倒影的距离后面的属性是设置倒影渐变 */
-webkit-box-reflect: below 15px -webkit-linear-gradient(transparent 50%,rgba(255,255,255,0.3));
}
.card img{
width: 100%;
height: 100%;
}
/* 为每一个卡片设置初始化位置和旋转角度 */
.card:nth-child(1){
transform: rotateY(0) translateZ(700px);
}
.card:nth-child(2){
transform: rotateY(120deg) translateZ(700px);
}
.card:nth-child(3){
transform: rotateY(240deg) translateZ(700px);
}
/* 定义动画 */
@keyframes cardRotate {
0%,20%{
transform: translateZ(-700px) rotateY(0);
}
45%{
transform: translateZ(-700px) rotateY(-120deg);
}
75%{
transform: translateZ(-700px) rotateY(-240deg);
}
100%{
transform: translateZ(-700px) rotateY(-360deg);
}
}

28
html/43.html Normal file
View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>3D轮播卡片</title>
<link rel="stylesheet" href="../css/43.css">
</head>
<body>
<div class="container">
<div class="card-box">
<div class="card">
<img src="../images/op/1.jpg" alt="">
</div>
<div class="card">
<img src="../images/op/2.jpg" alt="">
</div>
<div class="card">
<img src="../images/op/3.jpg" alt="">
</div>
</div>
</div>
</body>
</html>