核心属性
overflow: hidden “滑动打开”时将超出矩形范围的图片裁剪掉
background-size: cover 背景图完全覆盖背景区域,但是可能会有部分看不到
clip-path 裁剪图片(road-to-nowhere.jpg)分别为上下两部分
hover + transition + transform: translateY( ) 鼠标悬停时图片分别上下移动自身高度的45%距离
相关知识
《CSS3/SVG clip-path路径剪裁遮罩属性简介》
-
<base href="https://pics.codecolor.cn/sliding-door-images/">
-
<figure>
-
<figcaption><div>路无尽头</div><div>脚不停止</div></figcaption>
-
<img src="road-to-nowhere.jpg" alt="">
-
<img src="road-to-nowhere.jpg" alt="">
-
</figure>
-
* { -
box-sizing: border-box;
-
}
-
body { -
margin: 0;
-
background: #222;
-
}
-
figure { -
position: relative;
-
width: 60vw;
-
height: 60vw;
-
margin: 0 auto;
-
overflow: hidden;
-
background-image: url(https://pics.codecolor.cn/sliding-door-images/mad-dog.jpg);
-
background-size: cover;
-
}
-
figure img { -
position: absolute;
-
top: 0;
-
left: 0;
-
width: 100%;
-
transition: 2s ease-in-out;
-
}
-
figure img:first-of-type { -
clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);
-
}
-
figure img:last-of-type { -
clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
-
}
-
figure:hover img:first-of-type { -
transform: translateY(-45%);
-
}
-
figure:hover img:last-of-type { -
transform: translateY(45%);
-
}
-
figcaption { -
position: absolute;
-
top: 0;
-
width: 100%;
-
height: 100%;
-
padding-top: 12vw;
-
color: white;
-
font-size: 10vw;
-
text-align: center;
-
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 鼠标悬停动画效果
- 大图背景悬停导航菜单
- 图片不同方向悬停显示不同文字
- 按钮悬停边框和背景动画集合
- 文字悬停下划线动画效果集合
- BannerHoverView - 解耦 TableView Header 实现悬停
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
PHP+MySQL八大动态Web应用实战
Jono Bacom / 吴连河、李剑 / 电子工业出版社 / 2008-6 / 68.00元
本书详细介绍了利用PHP+MySQL开发常见类型Web应用程序的完整设计和编码技术,并对整体设计与关键代码给予了细致、深入的剖析。其内容注重实践,提供了翔实完整的实战代码;思路独树一帜,突破过多描述语言细节的窠臼;行文风趣幽默,轻松调侃中将项目的完整设计过程分析得一清二楚。书中的示例项目完整而实用,读者甚至无需任何改动即可在实际中加以运用。. 本书适合对PHP/MySQL有初步了解但缺乏完整......一起来看看 《PHP+MySQL八大动态Web应用实战》 这本书的介绍吧!