css春夏秋冬,鼠标滑入动效展示

效果展示

图片素材

代码块

html 复制代码
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<style>
			* {
				margin: 0;
				padding: 0;
			}
			
			.box {
				width: 800px;
				height: 300px;
				display: flex;
			}
			
			.box .item {
				transition: 0.5s;
				position: relative;
			}
			
			.box .item p {
				display: flex;
				justify-content: center;
				align-items: center;
				color: #FFF;
				font-size: 60px;
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
			}
			
			.box .item img {
				width: 100%;
				height: 100%;
				object-fit: cover;
			}
			
			.box .item1 {
				flex: 1;
			}
			
			.box .item1:hover {
				flex: 5;
			}
			
			.box .item1:hover~.item2,
			.box .item1:hover~.item3,
			.box .item1:hover~.item4 {
				flex: 1;
			}
			
			.box .item2 {
				flex: 1;
			}
			
			.box .item2:hover {
				flex: 5;
			}
			
			.box .item2:hover~.item1,
			.box .item2:hover~.item3,
			.box .item2:hover~.item4 {
				flex: 1 ;
			}
			
			.box .item3 {
				flex: 1;
			}
			
			.box .item3:hover {
				flex: 5;
			}
			
			.box .item3:hover~.item1,
			.box .item3:hover~.item2,
			.box .item3:hover~.item4 {
				flex: 1;
			}
			
			.box .item4 {
				flex: 1;
			}
			
			.box .item4:hover {
				flex: 5;
			}
			
			.box .item4:hover~.item1,
			.box .item4:hover~.item2,
			.box .item4:hover~.item3 {
				flex: 1;
			}
		</style>
		<div class="box">
			<div class="item item1">
				<p>春</p>
				<img src="./img/1.jpg" alt="" />
			</div>
			<div class="item item2">
				<p>夏</p>
				<img src="./img/2.jpg" alt="" />
			</div>
			<div class="item item3">
				<p>秋</p>
				<img src="./img/3.jpg" alt="" />
			</div>
			<div class="item item4">
				<p>冬</p>
				<img src="./img/4.jpg" alt="" />
			</div>
		</div>
	</body>
</html>
相关推荐
IT_陈寒2 分钟前
SpringBoot 3.2实战:我用这5个冷门特性将接口QPS提升了200%
前端·人工智能·后端
小流苏生7 分钟前
当你不再热爱自己的工作和生活……
前端·程序员·ai编程
Aliex_git8 分钟前
Vue 2 - 模板编译源码理解
前端·javascript·vue.js·笔记·前端框架
Thetimezipsby10 分钟前
Redux、React Redux 快速学习上手、简单易懂、知识速查
前端·react.js·redux
C_心欲无痕14 分钟前
css - 预处理器sass与后处理器postcss
css·sass·postcss
黎明初时15 分钟前
react基础框架搭建2-准备工作:react+router+redux+axios+Tailwind+webpack
前端·react.js·webpack
threerocks23 分钟前
我的年终总结 - 艰难的 2025
前端·面试·年终总结
随祥1 小时前
Tauri+vue开发桌面程序环境搭建
前端·javascript·vue.js
万少6 小时前
HarmonyOS官方模板集成创新活动-流蓝卡片
前端·harmonyos
-To be number.wan8 小时前
C++ 赋值运算符重载:深拷贝 vs 浅拷贝的生死线!
前端·c++