CSS 实现 图片鼠标悬停折叠效果
1. 实现要点
&nbs p; 折叠是由多个块级元素来完成的; 图片是以背景图片的方式呈现出来的; 给每个块级元素设置同一张背景图片,通过background-pos IT ion来控制显示的区域(类似于雪碧图); 通过ransform属性来实现折叠效果; 整个包裹div的大小就是图片的原大小,如果更改了 尺寸 ,需要 调整 background-size 等属性调整 背景图片大小2. 效果展示
3. 源 码
<!DOCTY PE ht ML >
<html lang="en">
<head>
< ;m eta charset="UTF-8">
<meta n am e="viewport" content="width=device-width, initial -s cale=1.0">
<title>hover-folder</title>
<style>
html,
body,
ul,
li {
m arg in: 0;
padding: 0
}
ul {
list-style: none;
dis play : block;
}
body {
width: 100%;
h ei ght: 100vh;
}
.cont ai ner {
width: 100%;
height: 100%;
/* background-color: aqua; */
display: flex;
justify-content: center ;
align -i tems: center;
transform: scale(0.5);
}
.wrap {
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .5);
width: 1280px;
height: 854px;
font- Size: 0;
line-height: 0;
position: relative;
}
.image {
cursor: pointer;
}
.abs-wrap {
height: 100%;
width: 100%;
/* top: 0;
left: 0; */
/* position: absolute; */
z-index: 10;
}
.abs-wrap:hover>.abs:nth-child(2) {
transform: matrix(0.8, -0.2, 0, 1, -1, 0);
}
.abs-wrap:hover>.abs:nth-child(3) {
transform: matrix(0.8, 0.2, 0, 1, -53, -50);
}
.abs-wrap:hover>.abs:nth-child(4) {
transform: matrix(0.8, -0.2, 0, 1, -105, 0);
}
.abs-wrap:hover>.abs:nth-child(5) {
transform: matrix(0.8, 0.2, 0, 1, -157, -50);
}
.abs {
transform-style: PR eserve-3d;
transform-ori gin : left center;
transition: .4s ease-in-out;
width: 20%;
height: 100%;
/* background-color: rgba(0, 0, 0, .5); */
display: inline-block;
background-size: 100%;
background: url('https://t img sa.baidu .COM /timg?image&quality=80&size=b9999_10000&sec=1600577868615&di=d2979a54604ecb409e3329527d0220fa&imgtype=0&src=http%3A%2F%2Ft9.baidu测试数据%2Fit%2Fu%3D29311073%2C358824429%26fm%3D79%26app%3D86%26f%3DJPEG%3Fw%3D1280%26h%3D854');
}
.abs:nth-child(1) {
background-position: 0% 0%;
}
.abs:nth-child(2) {
background-position: 25% 0%;
}
.abs:nth-child(3) {
background-position: 50% 0%;
}
.abs:nth-child(4) {
background-position: 75% 0%;
}
.abs:nth-child(5) {
background-position: 100% 0%;
}
</style>
</head>
<body>
<div class="container">
<div class="wrap">
<ul class="abs-wrap">
<li class="abs"></li>
<li class="abs"></li>
<li class="abs"></li>
<li class="abs"></li>
<li class="abs"></li>
</ul>
</div>
</div>
</body>
</html>
总结
到此这篇关于CSS 实现 图片鼠标悬停折叠效果的 文章 就介绍到这了,更多相关css图片鼠标悬停折叠内容请搜索以前的文章或继续浏览下面的相关文章,希望大家以后多多支持!
总结
以上是 为你收集整理的 CSS 实现 图片鼠标悬停折叠效果 全部内容,希望文章能够帮你解决 CSS 实现 图片鼠标悬停折叠效果 所遇到的问题。
如果觉得 网站内容还不错, 推荐好友。
查看更多关于CSS 实现 图片鼠标悬停折叠效果的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did201495