div+css实现可爱南瓜头鼠标悬停图文卡片效果代码

代码语言:html

所属分类:悬停

代码描述:div+css实现可爱南瓜头鼠标悬停图文卡片效果代码

代码标签: div css 可爱 南瓜头 鼠标 悬停 图文 卡片

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

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

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

  
<style>
@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	font-family: "Inter", sans-serif;
}

body {
	background-color: #1e1e1e;
	display: grid;
	place-items: center;
	min-height: 100vh;
}

.button-group {
	width: 300px;
	height: 300px;
	display: grid;
	position: relative;
	gap: 0.5rem;

	&::before {
		position: absolute;
		content: "";
		top: 0;
		width: 1rem;
		height: 5rem;
		left: 50%;
		background-color: #6ec207;
		translate: 5% -90%;
		border-top-left-radius: 2rem;
		border-top-right-radius: 1rem;
		rotate: 18deg;
		z-index: -1;
	}

	&::after {
		position: absolute;
		content: "";
		top: 0;
		width: 1rem;
		height: 3rem;
		left: 50%;
		background-color: #6ec207;
		translate: -100% -90%;
		border-top-left-radius: 2rem;
		border-top-right-radius: 1rem;
		rotate: -22deg;
		z-index: -1;
	}
}

.overlay {
	position: absolute;
	inset: 0px;

	background-image: linear-gradient(
		to right,
		#e6b980 0%,
		#e6b980 31%,
		#1e1e1e 31%,
		#1e1e1e 33%,
		#e8c392 33%,
		#e8c392 66%,
		#1e1e1e 66%,
		#1e1e1e 68%,
		#eacda3 68%,
		#eacda3 100%
	);

	z-index: 1;
	border-radius: 2rem;
	display: grid;
	place-content: center;
	transition: opacity 300ms ease-in-out;
	pointer-events: none;
	font-size: 1rem;
	text-transform: uppercase;
	letter-spacing: 2px;
	gap: 1rem;

	.eyes {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 250px;
	}

	.eye {
		width: 2rem;
		height: 2rem;
		display: inline-block;
		background-color: #1e1e1e;
		border-radius: 50%;
		position: relative;
		overflow: hidden;
		transition: rotate 10ms linear;

		&::before {
			position: absolute;
			content: "";
			width: 1rem;
			height: 1rem;
			background-color: #fff;
			border-radius: 50%;
		}
	}
}

.fancy-button {
	border: none;
	outline: none;
	border-radius: 0.5rem;
	position: relative;
	overflow: hidden;
}

.moving-text {
	position: absolute;
	color: var(--var-color);
	font-size: 2rem;
	text-transform: uppercase;
	font-weight: bold;
	top: 50%;
	transition: opacity 300ms ease-in-out, translate 300ms ease-in-out;
	transition-delay: 300ms;

	&:first-of-type {
		translate: calc(var(--var-translateX) - 10%) -50%;
		left: 1.5rem;
		opacity: calc(1 - var(--var-opacity));
	}
	&:last-of-type {
		translate: var(--var-translateX) -50%;
		right: 1.5rem;
		opacity: var(--var-opacity);
	}
}

.moving-image {
	position: absolute;
	width: 7rem;
	aspect-ratio: 1;
	top: 50%;
	left: 2rem;
	translate: var(--var-image-pos);
	transition: scale 300ms ease-in-out, translate 300ms ease-in-out;
	transition-delay: 300ms;

	& > svg {
		width: 100%;
		height: 100%;
	}
}

.top {
	--var-opacity: 1;
	--var-translateX: 0%;
	--var-image-pos: 0 -50%;
	--var-color: #fff;

	border-top-left-radius: 2rem;
	border-top-right-radius: 2rem;
	background-image: linear-gradient(-20deg, #fc6076 0%, #ff9a44 100%);

	&:hover {
		--var-opacity: 0;
		--var-translateX: 20%;
		--var-image-pos: 175% 0%;

		.moving-image {
			scale: 2;
		}
	}
}

.static-text {
	font-size: 2rem;
	font-weight: bold;
	text-transform: uppercase;
}

.shaking-image {
	position: absolute;
	width: 4rem;
	height: 4rem;
	bottom: 0%;
	left: 50%;
	opacity: 0;
	transition: translate 100ms ease-in-out, scale 300ms ease-in-out,
		opacity 300ms ease-in-out;
	transition-delay: 0ms, 100ms;
	transform-origin: bottom;
	translate: -50% 100%;

	& > svg {
		width: 100%;
		height: 100%;
	}
}

.bottom {
	border-bottom-left-radius: 2rem;
	border-bottom-right-radius: 2rem;
	background-image: linear-gradient(to top, #0fd850 0%, #f9f047 100%);

	&:hover .shaking-image {
		scale: 2;
		opacity: 1;
	}
}

.button-group:hover > .overlay {
	opacity: 0;
}
</style>



  
  
</head>

<body translate="no">
  <div class="button-group">
	<button class="fancy-button top">
		<span class="moving-text">Treat!!</span>
		<span class="moving-image">
			<svg height="200px" width="200px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 512.008 512.008" xml:space="preserve" fill="#000000">
				<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
				<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
				<g id="SVGRepo_iconCarrier">
					<path style="fill:#FF4F18;" d="M11.508,112.46l11.879,11.654c28.108,27.576,73.247,27.145,100.82-0.96 c27.577-28.11,27.144-73.248-0.964-100.824l-11.879-11.654L11.508,112.46z"></path>
					<path style="fill:#FF7953;" d="M46.693,100.359L34.813,88.705L11.508,112.46l11.879,11.654 c28.108,27.576,73.247,27.145,100.822-0.963c4.031-4.109,7.405-8.517,10.241-13.247C107.157,126.987,70.691,123.904,46.693,100.359z "></path>
					<path style="fill:#EE2300;" d="M99.948,46.076L88.069,34.422l23.305-23.756l11.879,11.654 c28.108,27.576,28.541,72.714,0.965,100.822c-4.031,4.109-8.542,7.665-13.217,10.59C127.56,106.116,123.948,69.619,99.948,46.076z"></path>
					<path style="fill:#FF4F18;" d="M500.498,399.56l-11.879-11.654c-28.108-27.576-73.247-27.145-100.82,0.96 c-27.577,28.11-27.144,73.248,0.964,100.824l11.879,11.654L500.498,399.56z"></path>
					<path style="fill:#FF7953;" d="M412.068,465.934l11.879,11.654l-23.305,23.755l-11.879-11.654 c-28.108-27.576-28.541-72.714-0.965-100.822c4.031-4.109,8.513-7.442,13.187-10.368 C384.428,406.116,388.069,442.391,412.068,465.934z"></path>
					<path style="fill:#EE2300;" d="M465.314,411.66l11.879,11.654l23.305-23.755l-11.879-11.654 c-28.108-27.576-73.247-27.145-100.822,0.963c-4.031,4.109-7.278,8.655-10.114,13.384 C404.977,385.169,441.314,388.117,465.314,411.66z"></path>
					<path style="fill:#FFD92D;" d="M389.602,387.068L389.602,387.068c-43.997,44.847-116.018,45.534-160.864,1.539L123.963,285.816 c-44.847-43.997-45.534-116.018-1.539-160.864l0,0c43.997-44.847,116.018-45.534,160.864-1.539l104.776,102.792 C432.911,270.202,433.6,342.223,389.602,387.068z"></path>
					<path style="fill:#FFE571;" d="M256.122,361.223L151.346,258.432c-40.391-39.626-44.943-101.976-13.308-146.739 c-5.493,3.887-10.734,8.285-15.614,13.259l0,0c-43.997,44.847-43.308,116.868,1.539,160.864l104.776,102.792 c44.847,43.997,116.868,43.308,160.864-1.539l0,0c4.371-4.455,8.281-9.187,11.77-14.125 C357.332,404.104,295.994,400.341,256.122,361.223z"></path>
					<path style="fill:#FFA81E;" d="M388.064,226.205L283.288,123.413c-44.847-43.997-116.868-43.308-160.864,1.539l0,0 c-4.406,4.491-8.341,9.263-11.851,14.243c44.03-31.058,105.287-27.264,145.12,11.814l104.776,102.792 c40.356,39.592,44.933,101.866,13.39,146.62c5.542-3.909,10.826-8.339,15.744-13.352l0,0 C433.6,342.223,432.911,270.202,388.064,226.205z"></path>
					<g>
						<path style="fill:#FF4F18;" d="M262.229,107.098L118.005,279.513c1.891,2.158,3.877,4.26,5.958,6.303l20.935,20.539 l146.431-175.054l-8.041-7.888C276.786,117.033,269.707,111.6,262.229,107.098z"></path>
						<polygon style="fill:#FF4F18;" points="175.845,336.715 202.948,363.306 349.379,188.252 322.276,161.662 "></polygon>
						<path style="fill:#FF4F18;" d="M380.325,218.612l-146.28,174.873c9.966,8.625,21.061,15.235,32.763,19.826l138.479-165.547 c-4.744-7.694-10.481-14.945-17.222-21.559L380.325,218.612z"></path>
					</g>
					<g>
						<path style="fill:#EE2300;" d="M266.22,161.323l25.109-30.021l-2.44-2.393l-5.6-5.495c-0.008-0.006-0.014-0.013-0.022-0.02 c-0.758-0.743-1.525-1.471-2.298-2.188c-0.231-0.214-0.466-0.423-0.698-0.634c-0.562-0.513-1.126-1.021-1.695-1.522 c-0.257-0.225-0.516-0.447-0.774-0.67c-0.566-0.488-1.134-0.969-1.707-1.444c-0.242-0.2-0.484-0.399-0.727-0.597 c-0.625-0.509-1.256-1.011-1.89-1.505c-0.187-0.146-0.373-0.293-0.562-0.438c-0.773-0.595-1.553-1.181-2.337-1.753 c-0.05-0.036-0.099-0.074-0.149-0.11c-2.672-1.942-5.408-3.753-8.2-5.435l-24.69,29.519c6.512,4.165,12.919,8.779,18.658,14.41 L266.22,161.323z"></path>
						<polygon style="fill:#EE2300;" points="349.379,188.252 322.276,161.662 297.149,191.689 324.254,218.279 "></polygon>
						<path style="fill:#EE2300;" d="M405.147,247.68c-4.744-7.694-10.481-14.945-17.222-21.559l-7.739-7.592l-24.976,30.11l5.86,5.305 c7.512,7.369,13.575,15.767,18.6,24.447L405.147,247.68z"></path>
					</g>
					<g>
						<path style="fill:#FF7953;" d="M290.948,384.452c-11.507-4.884-22.377-11.752-32.095-20.624l-24.808,29.657 c3.715,3.216,7.588,6.149,11.592,8.805c0.043,0.029,0.088,0.059,0.131,0.088c1.311,0.867,2.635,1.704,3.973,2.512 c0.033,0.02,0.066,0.039,0.099,0.059c2.649,1.595,5.351,3.068,8.094,4.427c0.124,0.061,0.247,0.124,0.371,0.185 c1.305,0.641,2.62,1.253,3.943,1.84c0.159,0.07,0.318,0.14,0.479,0.209c1.351,0.592,2.709,1.162,4.077,1.699 c0.001,0,0.003,0.001,0.004,0.001L290.948,384.452z"></path>
						<polygon style="fill:#FF7953;" points="227.847,333.541 200.742,306.949 175.845,336.715 190.323,350.92 202.948,363.306 "></polygon>
						<path style="fill:#FF7953;" d="M144.898,306.354l24.899-29.765L151.052,258.2c-2.836-2.783-5.477-5.689-7.959-8.682l-25.09,29.995 c0.001,0.001,0.001,0.003,0.003,0.004c0.842,0.96,1.709,1.905,2.588,2.843c0.211,0.225,0.423,0.45,0.637,0.674 c0.893,0.937,1.798,1.867,2.731,2.782L144.898,306.354z"></path>
					</g>
					<g>
						<path style="fill:#1C2042;" d="M323.514,175.847l4.991,5.289c2.024,2.144,4.803,3.145,7.532,2.979 c2.155-0.131,4.278-0.99,5.971-2.587c3.838-3.62,4.012-9.666,0.391-13.503l-4.991-5.289c-3.62-3.836-9.666-4.012-13.503-0.391 C320.067,165.963,319.893,172.009,323.514,175.847z"></path>
						<path style="fill:#1C2042;" d="M508.693,395.067l-11.747-11.789c-15.242-15.298-35.53-23.745-57.125-23.784 c-7.299-0.015-14.445,0.954-21.308,2.803c8.178-16.633,12.524-35.039,12.559-54.119c0.06-32.935-12.711-63.923-35.958-87.255 l-22.984-23.067c-3.723-3.737-9.771-3.747-13.51-0.024c-3.737,3.724-3.748,9.771-0.024,13.51l22.984,23.067 c29.046,29.15,37.217,71.328,24.57,107.821c-3.825-16.267-13.395-33.344-28.192-48.194c-3.723-3.736-9.771-3.747-13.51-0.024 c-3.737,3.723-3.748,9.771-0.024,13.51c23.624,23.709,31.585,55.691,17.388,69.836c-12.84,12.791-15.512,15.457-51.63-7.856 c-4.432-2.859-10.346-1.586-13.207,2.845c-2.861,4.432-1.587,10.345,2.845,13.206c12.31,7.945,22.233,13.888,30.96,17.297 c-38.447,17.378-85.341,10.259-116.832-21.346l-103.6-103.976c-29.359-29.4.........完整代码请登录后点击上方下载按钮下载查看

网友评论0