纯css+html实现发光伸缩卡片

效果展示

相信很多人都自学过css3,基础知识都知道但是没有很深刻的理解。我一直认为想要深刻理解,没有比在项目中应用更有效的方法了。
因为我本身是学后端的,前端css3这块也是最近写后端项目太累了,写写放松一下。废话不多说
先来看一下效果展示
在这里插入图片描述
在这里插入图片描述
使用css3+html,对整个body实现flex布局
在每个div的before和after属性上实现高斯模糊+颜色线性渐变效果进行渲染,
上下回缩是由hover引起height变化,由过渡时间渲染
对每个图片实现伸缩前后透明度变化

这里有我写好的效果网页,可以自己看一下
闪光伸缩卡片效果展示

代码展示

*{
			     margin: 0;
			     padding: 0;
			}
			body
			{
				/* flex布局 */
				display: flex;
				/* 页面主轴居中排列 */
				justify-content: center;
				/* 一行排不下自动换行 */
				flex-wrap: wrap;
			     /* 纵轴居中排列 */
				align-items: center;
				/* 元素最小高度 整个视窗高度的 1%  弹性布局 */
				min-height: 100vh;
				background-color: #010615;
			}
			 .box
			{
				position: relative;/* 子元素的定位 */
				/* 容器宽高 */
				width: 300px;
				height: 500px;
				/* flex布局 */
				display: flex;
				/* 页面主轴居中排列 */
				justify-content: center;
				align-items: center;
				/* 外边框 */
				margin: 40px;
			    background: #060c21;
				transition: 0.5s;
			} 
			 .box .imagebox
			{
				/* 绝对定位 */
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100%;
				/* 内边距 */
				padding: 10px;
			} 
			/* 鼠标放上去时 */
			.box:hover
			{
				height: 600px;
			}
			.box .imagebox img
			{
				max-width: 280px;
			    /* 透明度 */
				opacity: 0.1;
			    /* 持续时间 */
				transition: 0.5s;
			}
			.box:hover .imagebox img
			{
				max-width: 280px;
				opacity:1;
			}
			
			/* box属性之前加一个高斯模糊 */
			.box::before
			{
				/* 必须加入字符串,before和after才能有效果 */
				content: "";
				position: absolute;
				top: -2px;
				left: -2px;
				right: -2px;
				bottom: -2px;
			    background: #FFFFFF;
				z-index: -1;
				/* 给图像加一个高斯模糊 */
				filter: blur(40px);
			}
			
			/* box属性之后加一个高斯模糊 */
			.box::after
			{
				/* 必须加入字符串,before和after才能有效果 */
				content: "";
				position: absolute;
				top: -2px;
				left: -2px;
				right: -2px;
				bottom: -2px;
				 background: #FFFFFF; 
				z-index: -2;
				/* 给图像加一个高斯模糊 */
				filter: blur(40px);
			}
			
			/* 进行渲染 */
			/* box对应的父元素匹配的子元素中的属性 */
			 .box:nth-child(1)::before,.box:nth-child(1)::after
			{
			/* 背景色:线性渐变 */
				background: linear-gradient(235deg,#89ff00,#010615,#00bcd4);
			}
			.box:nth-child(2)::before,.box:nth-child(2)::after
			{
				background: linear-gradient(235deg,#ff005e,#010615,#fbff00);
			}
			.box:nth-child(3)::before,.box:nth-child(3)::after
			{
				background: linear-gradient(235deg,#772aff,#010615,#2196fc);
			} 
			
			.box .content
			{
				position: absolute;
			    height: 90px;
				left: 10px;
				right: 10px;
				bottom: 10px;
				text-align: center;
				display: flex;
				justify-content: center;
				align-items: center;
				/* 设置文字容器为透明 */
				opacity: 0;
				/* 过度的效果,时长 */
				transition: 0.5s;
			}
			
			.box:hover .content
			{
				opacity: 1;
			}
			
			.box .content h2
			{
				font-size: 20px;
				color:  #FFFFFF;
				font-weight: 500;
				line-height: 20px;
				letter-spacing: 1px;
			}
			.box .content h2 span
			{
				font-size: 14px;
				color:  #FFFFFF;
				font-weight: 200;
				line-height: 20px;
				letter-spacing: 1px;
			}
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值