Home > Web Front-end > CSS Tutorial > How to Create a CSS Zoom Effect on Hover Without Tables or Masks?

How to Create a CSS Zoom Effect on Hover Without Tables or Masks?

Mary-Kate Olsen
Release: 2024-11-28 21:19:11
Original
244 people have browsed it

How to Create a CSS Zoom Effect on Hover Without Tables or Masks?

CSS Zoom Effect on Hover Using Transform

Question:

How can I create a zoom effect on mouse hover on a HTML image without using tables or mask divs?

Answer:

Using the Transform Property with Scale

Consider utilizing CSS3's transform property to achieve a zoom-like effect using scale. Here's how:

HTML:

<div class="thumbnail">
    <div class="image">
        <img src="path/to/image.jpg" alt="Image hover effect">
    </div>
</div>
Copy after login

CSS:

.thumbnail {
    width: desired-width;
    height: desired-height;
}

.image {
    width: 100%;
    height: 100%;    
}

.image img {
    transition: all 1s ease;
}

.image:hover img {
    transform: scale(1.25);  
}
Copy after login

Demo Explanation:

  • The scale() value indicates the multiplier for the image's original size, resulting in a 25% zoom effect.
  • The transition property specifies the smooth transition of the zoom effect.
  • This approach avoids using additional elements or CSS tricks, making it a simple and efficient way to achieve the desired zoom effect.

The above is the detailed content of How to Create a CSS Zoom Effect on Hover Without Tables or Masks?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template