【css酷炫效果】纯css实现液体按钮效果

【css酷炫效果】纯css实现液体按钮效果

想直接拿走的老板,链接放在这里:https://download.csdn.net/download/u011561335/90490497

创作随缘,不定时更新。

创作背景

刚看到csdn出活动了,赶时间,直接上代码。

html结构

clike 复制代码
<button class="liquid-btn-1">Hover Me</button>

css样式

clike 复制代码
.liquid-btn-1 {
  padding: 15px 30px;
  font-size: 1.2rem;
  background: #2196f3;
  color: white;
  border: none;
  border-radius: 50px;
  position: relative;
  overflow: hidden;
  transition: 0.8s;
  cursor: pointer;
}

.liquid-btn-1:hover {
  background: #1565c0;
  box-shadow: 0 0 20px rgba(33,150,243,0.5);
}

.liquid-btn-1::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255,255,255,0.4),
    transparent
  );
  transition: 0.8s;
}

.liquid-btn-1:hover::before {
  left: 100%;
}

完整代码

基础版

clike 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS Liquid Button</title>
    <style>
	.liquid-btn-1 {
	  padding: 15px 30px;
	  font-size: 1.2rem;
	  background: #2196f3;
	  color: white;
	  border: none;
	  border-radius: 50px;
	  position: relative;
	  overflow: hidden;
	  transition: 0.8s;
	  cursor: pointer;
	}

	.liquid-btn-1:hover {
	  background: #1565c0;
	  box-shadow: 0 0 20px rgba(33,150,243,0.5);
	}

	.liquid-btn-1::before {
	  content: '';
	  position: absolute;
	  top: 0;
	  left: -100%;
	  width: 100%;
	  height: 100%;
	  background: linear-gradient(
		90deg,
		transparent,
		rgba(255,255,255,0.4),
		transparent
	  );
	  transition: 0.8s;
	}

	.liquid-btn-1:hover::before {
	  left: 100%;
	}
    </style>
</head>
<body>
    <div class="liquid-button">
	<button class="liquid-btn-1">Hover Me</button>
    </div>
</body>
</html>

进阶版(动态边框)

clike 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS Liquid Button</title>
    <style>
	.liquid-btn-3 {
	  padding: 18px 36px;
	  font-size: 1.3rem;
	  background: linear-gradient(90deg, #4caf50, #8bc34a, #4caf50);
	  background-size: 200%;
	  color: white;
	  border: 2px solid transparent;
	  border-radius: 8px;
	  position: relative;
	  transition: 0.5s;
	  animation: bgFlow 3s linear infinite;
	}

	.liquid-btn-3::before {
	  content: '';
	  position: absolute;
	  top: -2px;
	  left: -2px;
	  right: -2px;
	  bottom: -2px;
	  background: linear-gradient(90deg, 
		#4caf50, #fff, #8bc34a, #fff, #4caf50);
	  background-size: 400%;
	  z-index: -1;
	  border-radius: 8px;
	  animation: borderFlow 4s linear infinite;
	}

	@keyframes bgFlow {
	  0% { background-position: 0% }
	  100% { background-position: 200% }
	}

	@keyframes borderFlow {
	  0% { background-position: 0% }
	  100% { background-position: 400% }
	}
    </style>
</head>
<body>
    <div class="liquid-button">
		<button class="liquid-btn-3">动态边框液体按钮</button>
    </div>
</body>
</html>

效果图

相关推荐
顾安r19 小时前
11.8 脚本网页 星际逃生
c语言·前端·javascript·flask
Hello.Reader19 小时前
Data Sink定义、参数与可落地示例
java·前端·网络
im_AMBER19 小时前
React 17
前端·javascript·笔记·学习·react.js·前端框架
谷歌开发者20 小时前
Web 开发指向标 | Chrome 开发者工具学习资源 (六)
前端·chrome·学习
一晌小贪欢20 小时前
【Html模板】电商运营可视化大屏模板 Excel存储 + 一键导出(已上线-可预览)
前端·数据分析·html·excel·数据看板·电商大屏·大屏看板
发现你走远了20 小时前
连接模拟器网页进行h5的调试(使用Chrome远程调试(推荐)) 保姆级图文
前端·chrome
街尾杂货店&21 小时前
css - 实现三角形 div 容器,用css画一个三角形(提供示例源码)简单粗暴几行代码搞定!
前端·css
顺凡21 小时前
删一个却少俩:Antd Tag 多节点同时消失的原因
前端·javascript·面试
小白路过21 小时前
CSS transform矩阵变换全面解析
前端·css·矩阵
爬山算法21 小时前
Redis(110)Redis的发布订阅机制如何使用?
前端·redis·bootstrap