Snippets: Hover Effects Collection
CSS Before Head
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" /> <link href="https://fonts.font.im/css2?family=Poppins:wght@700&display=swap" rel="stylesheet">
HTML Head
:root { --primary: #6366f1; --bg: #f1f5f9; --card: #ffffff; --text: #1e293b; --text-muted: #64748b; --border: #e2e8f0; --radius: 12px; --shadow: 0 4px 24px rgba(0,0,0,0.08); } * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding: 24px 16px; } .page-header { text-align: center; margin-bottom: 32px; } .page-header h1 { font-size: 1.75rem; font-weight: 700; color: var(--primary); margin-bottom: 6px; } .page-header p { color: var(--text-muted); font-size: 0.9rem; } .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; max-width: 1200px; margin: 0 auto; } .demo-cell { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; } .demo-cell.wide { grid-column: 1 / -1; } .demo-label { padding: 10px 16px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border); background: #f8fafc; } .demo-area { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 20px; min-height: 160px; background: #fff; overflow: hidden; position: relative; } /* ===== 001: Box Shadow Fill ===== */ .he-001 a { box-shadow: inset 0 0 0 0 #54b3d6; color: #54b3d6; padding: 0 .25rem; margin: 0 -.25rem; transition: color .3s ease-in-out, box-shadow .3s ease-in-out; font-family: "Poppins", sans-serif; font-size: 24px; font-weight: 700; line-height: 1.5; text-decoration: none; } .he-001 a:hover { color: #fff; box-shadow: inset 200px 0 0 0 #54b3d6; } /* ===== 002: Sliding Text Replace ===== */ .he-002 a { overflow: hidden; position: relative; display: inline-block; text-decoration: none; color: #18272F; font-family: "Poppins", sans-serif; font-size: 24px; font-weight: 700; vertical-align: top; } .he-002 a::before, .he-002 a::after { content: ""; position: absolute; width: 100%; left: 0; } .he-002 a::before { background-color: #54b3d6; height: 2px; bottom: 0; transform-origin: 100% 50%; transform: scaleX(0); transition: transform .3s cubic-bezier(0.76, 0, 0.24, 1); } .he-002 a::after { content: attr(data-replace); height: 100%; top: 0; transform-origin: 100% 50%; transform: translate3d(200%, 0, 0); transition: transform .3s cubic-bezier(0.76, 0, 0.24, 1); color: #54b3d6; } .he-002 a:hover::before { transform-origin: 0% 50%; transform: scaleX(1); } .he-002 a:hover::after { transform: translate3d(0, 0, 0); } .he-002 a span { display: inline-block; transition: transform .3s cubic-bezier(0.76, 0, 0.24, 1); } .he-002 a:hover span { transform: translate3d(-200%, 0, 0); } /* ===== 003: Gradient Text + Underline ===== */ .he-003 a { background-image: linear-gradient(to right, #54b3d6, #54b3d6 50%, #000 50%); background-size: 200% 100%; background-position: -100%; text-decoration: none; display: inline-block; padding: 5px 0; position: relative; -webkit-background-clip: text; -webkit-text-fill-color: transparent; transition: all 0.3s ease-in-out; font-family: "Poppins", sans-serif; font-size: 24px; font-weight: 700; } .he-003 a:before { content: ""; background: #54b3d6; display: block; position: absolute; bottom: -3px; left: 0; width: 0; height: 3px; transition: all 0.3s ease-in-out; } .he-003 a:hover { background-position: 0; } .he-003 a:hover::before { width: 100%; } /* ===== 004: Dual Gradient Underline ===== */ .he-004 a { color: inherit; text-decoration: none; font-family: "Poppins", sans-serif; font-size: 24px; font-weight: 700; background: linear-gradient(to right, rgba(100,200,200,1), rgba(100,200,200,1)), linear-gradient(to right, rgba(255,0,0,1), rgba(255,0,180,1), rgba(0,100,200,1)); background-size: 100% 3px, 0 3px; background-position: 100% 100%, 0 100%; background-repeat: no-repeat; transition: background-size 400ms; } .he-004 a:hover { background-size: 0 3px, 100% 3px; } /* ===== 005: Underline Scale ===== */ .he-005 a { color: #18272F; position: relative; text-decoration: none; font-family: "Poppins", sans-serif; font-size: 24px; font-weight: 700; } .he-005 a::before { content: ""; position: absolute; width: 100%; height: 4px; border-radius: 4px; background-color: #18272F; bottom: 0; left: 0; transform-origin: right; transform: scaleX(0); transition: transform .3s ease-in-out; } .he-005 a:hover::before { transform-origin: left; transform: scaleX(1); } /* ===== 006: Background Fill ===== */ .he-006 h3 { font-family: system-ui, sans-serif; font-size: 2.5rem; margin: 0; cursor: pointer; padding: 0 .07em; background: linear-gradient(#1095c1 0 0) left / var(--p, 0) no-repeat; transition: .4s, background-position 0s; color: #333; } .he-006 h3:hover { --p: 100%; background-position: right; color: #fff; } /* ===== 007: Bottom Highlight ===== */ .he-007 h3 { font-family: system-ui, sans-serif; font-size: 2.5rem; margin: 0; cursor: pointer; padding: 0 .07em; background: linear-gradient(#1095c1 0 0) no-repeat calc(200% - var(--i, 0)*100%) 100% / 200% calc(100%*var(--i, 0) + .08em); transition: .3s calc(var(--i, 0)*.3s), background-position .3s calc(.3s - calc(var(--i, 0)*.3s)); color: #333; } .he-007 h3:hover { --i: 1; } /* ===== 008: Dual Position ===== */ .he-008 h3 { font-family: system-ui, sans-serif; font-size: 2.5rem; margin: 0; cursor: pointer; padding: 0 .07em; --c: no-repeat linear-gradient(#1095c1 0 0); background: var(--c) calc(-101% + var(--i, 0)*101%) 100% / 50.1% calc(100%*var(--i, 0) + .08em), var(--c) calc(201% - var(--i, 0)*101%) 0 / 50.1% calc(100%*var(--i, 0) + .08em); transition: .3s calc(var(--i, 0)*.3s), background-position .3s calc(.3s - var(--i, 0)*.3s); color: #333; } .he-008 h3:hover { --i: 1; } /* ===== 009: Conic Gradient ===== */ .he-009 h3 { font-family: system-ui, sans-serif; font-size: 2.5rem; margin: 0; cursor: pointer; padding: 0 .07em; --c: #1095c1; line-height: 1.2em; background: conic-gradient(from -135deg at 100% 50%, var(--c) 90deg, #0000 0) 0 var(--p, 0%)/var(--s, 0%) 200% no-repeat, conic-gradient(from -135deg at 1.2em 50%, #0000 90deg, var(--c) 0) 100% var(--p, 0%)/var(--s, 0%) 200% no-repeat; transition: .4s ease-in, background-position 0s; color: #333; } .he-009 h3:hover { --p: 100%; --s: calc(50% + .61em); } /* ===== 010: Directional Box ===== */ .he-010 .box { position: relative; width: 10em; height: 10em; line-height: 10em; overflow: hidden; font-family: Helvetica, sans-serif; font-size: 14px; } .he-010 .box__right, .he-010 .box__left, .he-010 .box__top, .he-010 .box__bottom, .he-010 .box__center { position: absolute; width: inherit; height: inherit; text-align: center; line-height: 10em; transition: transform 0.4s ease; color: #fff; } .he-010 .box__right:before, .he-010 .box__left:before, .he-010 .box__top:before, .he-010 .box__bottom:before, .he-010 .box__center:before { position: absolute; content: ""; width: 70.71%; height: 70.71%; transform: rotate(45deg); } .he-010 .box__right:hover, .he-010 .box__left:hover, .he-010 .box__top:hover, .he-010 .box__bottom:hover, .he-010 .box__center:hover { transform: translateX(0); z-index: 1; } .he-010 .box__right:hover:before, .he-010 .box__left:hover:before, .he-010 .box__top:hover:before, .he-010 .box__bottom:hover:before, .he-010 .box__center:hover:before { width: 100%; height: 100%; transform: none; } .he-010 .box__right { background: #2BA7FB; transform: translateX(100%); } .he-010 .box__right:before { right: 100%; bottom: 0; transform-origin: 100% 100%; } .he-010 .box__right:hover ~ .box__center { transform: translateX(-100%); } .he-010 .box__left { background: #FD419C; transform: translateX(-100%); } .he-010 .box__left:before { left: 100%; transform-origin: 0 0; } .he-010 .box__left:hover ~ .box__center { transform: translateX(100%); } .he-010 .box__top { background: #AFCA00; transform: translateY(-100%); } .he-010 .box__top:before { top: 100%; right: 0; transform-origin: 100% 0; } .he-010 .box__top:hover ~ .box__center { transform: translateY(100%); } .he-010 .box__bottom { background: #ffd43b; transform: translateY(100%); } .he-010 .box__bottom:before { bottom: 100%; left: 0; transform-origin: 0 100%; } .he-010 .box__bottom:hover ~ .box__center { transform: translateY(-100%); } .he-010 .box__center { background: #47CF73; z-index: -1; } /* ===== 011: Photo Grid Slide ===== */ .he-011 { font: 14px/1.5 "Fira Sans", sans-serif; color: #333; width: 100%; padding: 0; } .he-011 .row { display: flex; } .he-011 .col { overflow: hidden; position: relative; color: #fff; flex: 1 1 auto; min-height: 130px; aspect-ratio: 2 / 1; } .he-011 .col h2 { font-weight: 300; font-size: 1.1rem; line-height: 1.25; margin: 0; position: absolute; bottom: 1rem; right: 1rem; z-index: 0; } .he-011 .slide { position: absolute; top: 0; right: 0; bottom: 0; left: 0; transition: all 0.275s ease-in-out, visibility 0s 0.275s; visibility: hidden; will-change: transform; transform: translateY(100%); } .he-011 .row:hover ~ .row .slide { transform: translateY(-100%); } .he-011 .row:hover .slide { transform: translateX(100%); } .he-011 .row:hover .col:hover ~ .col .slide { transform: translateX(-100%); } .he-011 .row:hover .col:hover .slide { transform: none; visibility: visible; transition-delay: 0s; } .he-011 .photo-container { background: #0f0523 50% 50%/cover; position: absolute; top: 0; right: 0; bottom: 0; left: 0; transition: 1s; transform-origin: bottom right; } /* ===== Profile Card ===== */ .he-profile { width: 100%; display: flex; justify-content: center; align-items: center; padding: 20px; background-image: linear-gradient(to right top, #051937, #004d7a, #008793, #00bf72, #a8eb12); border-radius: 0; } .he-profile .border { height: 230px; width: 180px; background: transparent; border-radius: 10px; transition: border 1s; position: relative; } .he-profile .border:hover { border: 1px solid #fff; } .he-profile .pcard { height: 240px; width: 190px; border-radius: 10px; transition: background 0.8s; overflow: hidden; background: #000; box-shadow: 0 70px 63px -60px #000; display: flex; justify-content: center; align-items: center; position: relative; background: url("https://img1.baidu.com/it/u=2928937623,1860035774&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=724") center center no-repeat; background-size: 190px; } .he-profile .pcard:hover { background: url("https://img1.baidu.com/it/u=2928937623,1860035774&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=724") left center no-repeat; background-size: 380px; } .he-profile .pcard:hover .name { opacity: 1; } .he-profile .pcard:hover .fa { opacity: 1; } .he-profile .name { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 28px; color: #fff; margin: 20px; opacity: 0; transition: opacity 1s; display: block; } .he-profile .fa { opacity: 0; transition: opacity 1s; } .he-profile .icons { position: absolute; fill: #fff; color: #fff; height: 130px; bottom: 20px; width: 50px; display: flex; flex-direction: column; align-items: center; justify-content: space-around; }
CSS After Head
JS Before HTML Body
HTML Body Attrs
<div style="max-width:1200px; margin:0 auto;"> <div class="page-header"> <h1>Hover Effects Collection</h1> <p>12 pure CSS hover effects — hover each demo to see the effect</p> </div> <div class="gallery"> <div class="demo-cell"> <div class="demo-label">001 — Box Shadow Fill</div> <div class="demo-area he-001"> <a href="javascript:void(0)">Hover this link</a> </div> </div> <div class="demo-cell"> <div class="demo-label">002 — Sliding Text Replace</div> <div class="demo-area he-002"> <a href="javascript:void(0)" data-replace="this link"><span>this link</span></a> </div> </div> <div class="demo-cell"> <div class="demo-label">003 — Gradient Text + Underline</div> <div class="demo-area he-003"> <a href="javascript:void(0)">Hover This Link</a> </div> </div> <div class="demo-cell"> <div class="demo-label">004 — Dual Gradient Underline</div> <div class="demo-area he-004"> <a href="javascript:void(0)">Hover this link</a> </div> </div> <div class="demo-cell"> <div class="demo-label">005 — Underline Scale</div> <div class="demo-area he-005"> <a href="javascript:void(0)">Hover this link</a> </div> </div> <div class="demo-cell"> <div class="demo-label">006 — Background Fill</div> <div class="demo-area he-006"> <h3>Hover Me</h3> </div> </div> <div class="demo-cell"> <div class="demo-label">007 — Bottom Highlight</div> <div class="demo-area he-007"> <h3>Hover Me</h3> </div> </div> <div class="demo-cell"> <div class="demo-label">008 — Dual Position</div> <div class="demo-area he-008"> <h3>Hover Me</h3> </div> </div> <div class="demo-cell"> <div class="demo-label">009 — Conic Gradient</div> <div class="demo-area he-009"> <h3>Hover Me</h3> </div> </div> <div class="demo-cell"> <div class="demo-label">010 — Directional Box Reveal</div> <div class="demo-area he-010"> <div class="box"> <div class="box__right">Right → Left</div> <div class="box__left">Left → Right</div> <div class="box__top">Top → Bottom</div> <div class="box__bottom">Bottom → Top</div> <div class="box__center">Hover from any side</div> </div> </div> </div> <div class="demo-cell"> <div class="demo-label">Profile Card</div> <div class="demo-area he-profile"> <div class="pcard"> <div class="border"> <span class="name">Jason Statham</span> <div class="icons"> <i class="fa fa-codepen" aria-hidden="true"></i> <i class="fa fa-instagram" aria-hidden="true"></i> <i class="fa fa-dribbble" aria-hidden="true"></i> <i class="fa fa-twitter" aria-hidden="true"></i> <i class="fa fa-facebook" aria-hidden="true"></i> </div> </div> </div> </div> </div> <div class="demo-cell wide"> <div class="demo-label">011 — Photo Grid Slide</div> <div class="demo-area he-011" style="padding:16px;"> <div> <div class="row"> <div class="col"><h2>Mountains</h2><div class="slide photo-container" style="background-image:url('https://picsum.photos/seed/mountains/600/300')"></div></div> <div class="col"><h2>Ocean</h2><div class="slide photo-container" style="background-image:url('https://picsum.photos/seed/ocean/600/300')"></div></div> <div class="col"><h2>Forest</h2><div class="slide photo-container" style="background-image:url('https://picsum.photos/seed/forest/600/300')"></div></div> <div class="col"><h2>Desert</h2><div class="slide photo-container" style="background-image:url('https://picsum.photos/seed/desert/600/300')"></div></div> </div> <div class="row"> <div class="col"><h2>City</h2><div class="slide photo-container" style="background-image:url('https://picsum.photos/seed/city2/600/300')"></div></div> <div class="col"><h2>Lake</h2><div class="slide photo-container" style="background-image:url('https://picsum.photos/seed/lake/600/300')"></div></div> <div class="col"><h2>Snow</h2><div class="slide photo-container" style="background-image:url('https://picsum.photos/seed/snow/600/300')"></div></div> <div class="col"><h2>Sunset</h2><div class="slide photo-container" style="background-image:url('https://picsum.photos/seed/sunset2/600/300')"></div></div> </div> </div> </div> </div> </div> </div>
HTML Body
HTML Foot
JS After HTML Body
Full HTML Code