css实现发光按钮悬浮动画效果代码

代码语言:html

所属分类:悬停

代码描述:css实现发光按钮悬浮动画效果代码

代码标签: css 发光 按钮 悬浮 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  
  
  
  
<style>
:root {
	--red: hsl(0, 100%, 80%);
	--yellow: hsl(62, 100%, 80%);
	--green: hsl(122, 100%, 80%);
	--blue: hsl(179, 100%, 80%);
	--purple: hsl(238, 100%, 80%);
	--pink: hsl(302, 100%, 80%);
	
	--fontPoppins: 'Poppins', sans-serif;
}

[type=submit], [type=reset], button, html [type=button] {
	-webkit-appearance: button;
	text-transform: none;
}

body {
	background: hsl(0 0% 4%);
	background: hsl(210 14% 11%);
	background: hsl(228 6% 15%);
	padding: 100px;
	margin: 0;
}

.glowButtonWrapper {
	position: relative;
	margin: 1.25em auto;
	padding: 0;
	display: table;
	transition: all 150ms linear;
}

.glowButtonWrapper:hover {
	transform: scale(1.15);
}

.glowButtonWrapper:active {
	transform: scale(0.95);
}

.glowButtonWrapper .glowButton {
	--angle: 0deg;
	--buttonBorder: 4px;
	--buttonBorderRadius: 2.25em;
	--buttonBorderRadiusBefore: 3em;
	
	position: relative;
	display: flex;
	padding: 0.875em 2.1em;
	gap: 0.875em;
	font-size: 1em;
	align-items: center;
	border-radius: var(--buttonBorderRadius);
	font-weight: 160;
	border: 0;
	/* overflow: hidden; */
	transition: background 3ms linear;
	
	color: hsl(0, 0%, 98%);
	font-family: sans-serif;
	
	background: hsl(0 0% 0% / 0%);
	
	/* border: 2px solid transparent; */
	box-shadow: 0 0 3px hsl(0 0% 0% / 20%), 
		0 1px 6px hsl(0 0% 0% / 15%), 
		0 4px 8px hsl(0 0% 0% / 13%);
	z-index: 1;
}

.glowButtonWrapper:hover .glowButton {
	transition: background 3ms linear;
	
	background: conic-gradient(
		in hsl longer hue from var(--angle), 
		hsl(0, 100%, 80%) 0 0
	) border-box;
	background-repeat: no-repeat;
	background-size: 100% 100%;
	
	box-shadow: 
		0 0 3px hsl(0 35% 80% / 65%), 
		0 1px 6px hsl(60 15% 80% / 50%), 
		0 4px 8px hsl(120 48% 80% / 30%), 
		0 5px 11px hsl(5 20% 80% / 20%);
	
	mix-blend-mode: color-dodge;
	
	animation: angle 2s linear infinite;
}

@property --angle {
	syntax: '<angle>'; 
	initial-value: 0deg;
	inherits: false
}

/* target only Firefox */
@-moz-document url-prefix() {
	.glowButtonWrapper .glowButton {
		transition: all 250ms linear;
		background: transparent;
	}
	
    .glowButtonWrapper:hover .glowButton {
		--angleFX: 0deg;
		/* transition: background 3ms linear; */
		transition: background 3ms linear;
		background:
		conic-gradient(
			from var(--angleFX) at 50% 50%,
			var(--red),
			var(--yellow),
			var(--green),
			var(--blue),
			var(--purple),
			var(--pink),
			var(--red)
		) border-box;
		
		animation: angleFX 2s linear infinite;
    }
}

.glowButtonWrapper .glowButton:before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	/*
	width: calc(100% - 7.5px);
	height: calc(100% - 7.5px);
	*/
	width: 100%;
	height: 100%;
	transform: translate(-50%, -50%);
	margin: 0 auto;
	padding: 0;
	
	background: hsl(233 12% 13% / 1) padding-box;
	background:
	linear-gradient(
		to bottom,
		hsl(228 5% 20% / 1),
		hsl(228 4% 25% / 1)
	) padding-box;
	border: 1px solid hsl(210 14% 9% / 60%);
	
	border-radius: var(--buttonBorderRadiusBefore);
	z-index: -1;
}

.glowButtonWrapper:hover .glowButton:before {
	width: calc(100% - 7.2px);
	height: calc(100% - 7.2px);
	
	box-shadow: 0 1px 0px hsl(0 0% 45% / 100%) inset,
		0 0 2px hsl(0 0% 75% / 30%);
		
	background: hsl(0 0% 25% / 90%) padding-box;
	background:
	linear-gradient(
		to bottom,
		hsl(228 5% 20% / 88%),
		hsl(228 4% 25% / 92%)
	) padding-box;
}

@keyframes angle { to { --angle: 1turn; } }

@keyframes angleFX {
	00.00% { --angleFX: 0deg; background: conic-gradient( from var(--angleFX) at 50% 50%, var(--red), var(--yellow), var(--green), var(--blue), var(--purple), var(--pink), var(--red) ); }
	04.16% { --angleFX: 15deg; background: conic-gradient( from var(--angleFX) at 50% 50%, var(--red), var(--yellow), var(--green), var(--blue), var(--purple), var(--pink), var(--red) ); }
	08.32% { --angleFX: 30deg; background: conic-gradient( from var(--angleFX) at 50% 50%, var(--red), var(--yellow), var(--green), var(--blue), var(--purple), var(--pink), var(--red) ); }
	12.48% { --angleFX: 45deg; background: conic-gradient( from var(--angle.........完整代码请登录后点击上方下载按钮下载查看

网友评论0