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.........完整代码请登录后点击上方下载按钮下载查看
网友评论0