新增第103个小实例:纯CSS实现百叶窗图片切换效果
This commit is contained in:
parent
d3a43568c1
commit
635c6867de
|
@ -106,4 +106,5 @@
|
|||
99. HTML5+CSS3小实例:炫彩的发光字特效
|
||||
100. HTML5+CSS3+JS小实例:黑色的简约下拉菜单
|
||||
101. HTML5+CSS3小实例:浮雕效果的彩色loading动画
|
||||
102. HTML5+CSS3+JS小实例:切片式轮播图
|
||||
102. HTML5+CSS3+JS小实例:切片式轮播图
|
||||
103. HTML5+CSS3小实例:纯CSS实现百叶窗图片切换效果
|
|
@ -0,0 +1,40 @@
|
|||
*{
|
||||
/* 初始化 */
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
body{
|
||||
height: 100vh;
|
||||
/* 弹性布局 水平+垂直居中 */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
/* 渐变背景 */
|
||||
background: linear-gradient(to top,#a3bded,#6991c7);
|
||||
}
|
||||
.img1{
|
||||
width: 900px;
|
||||
height: 500px;
|
||||
background: url("../images/op1/1.jpg") no-repeat;
|
||||
/* 保持原有尺寸比例,裁切长边 */
|
||||
background-size: cover;
|
||||
/* 背景定位正中间 */
|
||||
background-position: center center;
|
||||
/* 弹性布局 */
|
||||
display: flex;
|
||||
}
|
||||
.img2{
|
||||
background: url("../images/op1/3.jpg") no-repeat;
|
||||
background-size: cover;
|
||||
/* 通过var函数调用自定义属性--i,计算每个元素的背景图水平定位 */
|
||||
background-position-x: calc(var(--i) * 10%);
|
||||
flex: 1;
|
||||
/* 默认沿Y轴旋转90度(看不见) */
|
||||
transform: rotateY(90deg);
|
||||
/* 设置过渡 */
|
||||
transition: 0.8s;
|
||||
}
|
||||
.img1:hover .img2{
|
||||
/* 鼠标移入,图2沿Y轴旋转0度(出现) */
|
||||
transform: rotateY(0deg);
|
||||
}
|
|
@ -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>纯CSS实现百叶窗图片切换效果</title>
|
||||
<link rel="stylesheet" href="../css/103.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="img1">
|
||||
<div class="img2" style="--i:0;"></div>
|
||||
<div class="img2" style="--i:1;"></div>
|
||||
<div class="img2" style="--i:2;"></div>
|
||||
<div class="img2" style="--i:3;"></div>
|
||||
<div class="img2" style="--i:4;"></div>
|
||||
<div class="img2" style="--i:5;"></div>
|
||||
<div class="img2" style="--i:6;"></div>
|
||||
<div class="img2" style="--i:7;"></div>
|
||||
<div class="img2" style="--i:8;"></div>
|
||||
<div class="img2" style="--i:9;"></div>
|
||||
<div class="img2" style="--i:10;"></div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue