div+css实现图片卡片悬浮高光交互动画效果代码

代码语言:html

所属分类:悬停

代码描述:div+css实现图片卡片悬浮高光交互动画效果代码

代码标签: div css 图片 卡片 悬浮 高光 交互 动画

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

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

<head>
  <meta charset="UTF-8">
  

  
  
<style>
body {
	height: 100vh;
	margin: 0px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.card {
	--grad-size: min(270vh, 90vw);
	width: min(90vh, 30vw);
	aspect-ratio: 1;
	margin: min(5vh, 1.67vw);
	border-radius: 10%;
	background-image: radial-gradient(#fff 0%, #555 30%, #222 50%);
	background-color: #222;
	background-position: calc(var(--mouse-x) * 1px - var(--grad-size) / 2)
		calc(var(--mouse-y) * 1px - var(--grad-size) / 2);
	transition: background-position 2s cubic-bezier(0, 0, 0, 1);
	background-attachment: fixed;
	background-size: var(--grad-size) var(--grad-size);
	background-repeat: no-repeat;
	overflow: hidden;
	cursor: pointer;
}

.card::before {
	content: "";
	width: min(90vh, 30vw);
	aspect-ratio: 1;
	border-radius: 10%;
	position: absolute;
	background-image: linear-gradient(
		135deg,
		#fff0 45%,
		#fff7 48% 52%,
		#fff0 55%
	);
	background-size: 300% 300%;
	background-position: 100% 100%;
	transition: background-position 0.3s linear;
}

.card:hover::before {
	background-position: 0% 0%;
}

.card > img {
	width: min(90vh, 30vw);
	aspect-ratio: 1;
	object-fit: cover;
}

.card >.........完整代码请登录后点击上方下载按钮下载查看

网友评论0