TipsBlocks Web Technique Library

PRACTICAL WEB TIP

← Back to library

Image Zoom

The image scales gently within its frame on hover.

Live Demo

Hover over the element or press Tab to focus.

Source Code

Copy the HTML, CSS or JavaScript you need for your project.

HTML
<a href="#" class="tb-tip-image tb-tip-image--zoom" aria-label="View project"><img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MjAiIGhlaWdodD0iMzIwIiB2aWV3Qm94PSIwIDAgNTIwIDMyMCI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJnIiB4Mj0iMSIgeTI9IjEiPjxzdG9wIHN0b3AtY29sb3I9IiM3Q0M0QzYiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM0NzY2OEIiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48cmVjdCB3aWR0aD0iNTIwIiBoZWlnaHQ9IjMyMCIgZmlsbD0idXJsKCNnKSIvPjxjaXJjbGUgY3g9IjM3MCIgY3k9IjgzIiByPSI0MyIgZmlsbD0iI0ZGRTNBNSIvPjxwYXRoIGQ9Ik0wIDMwMEwxMzUgMTM3TDI0NSAyNjdMMzE4IDE4N0w1MjAgMzIwSDBaIiBmaWxsPSIjMjM0NTY1Ii8+PHBhdGggZD0iTTAgMzIwTDE1MCAyMTJMMjk1IDMyMFoiIGZpbGw9IiMzQzc3OEMiLz48L3N2Zz4=" alt="Illustrated mountain landscape"><span>View project ↗</span></a>
CSS
 .tb-tip-image{display:block;position:relative;overflow:hidden;width:min(320px,100%);height:195px;border-radius:9px;box-shadow:0 8px 24px #13345719;color:white;text-decoration:none}
.tb-tip-image img{width:100%;height:100%;object-fit:cover;display:block;transition:transform .4s ease}
.tb-tip-image span{position:absolute;inset:auto 0 0;padding:18px;font:600 14px system-ui;background:linear-gradient(transparent,#071e3bbb)}
.tb-tip-image:hover img,.tb-tip-image:focus-visible img{transform:scale(1.15)}
.tb-tip-image:focus-visible{outline:3px solid #7360cd;outline-offset:4px}
@media(prefers-reduced-motion:reduce){.tb-tip-image img{transition:none}}

How to Use

Insert the HTML and add the CSS to your stylesheet. Adjust colors and sizes and avoid class conflicts.

Use Case

Portfolios, galleries and case studies.

Technical Notes

Keep controls usable on touch devices. Test keyboard focus and reduced-motion preferences.

Mobile:Verify focus and tap behavior on touch devices.

Browser:Uses modern CSS features.

Reduced Motion:Respects prefers-reduced-motion.