Daily Programming
CSS Knowledge
How to achieve the slow enlargement effect of images when hovering the mouse in css3? (image, text + video)How to achieve the slow enlargement effect of images when hovering the mouse in css3? (image, text + video)
This article mainly introduces you to the specific method to achieve the magnification effect when the mouse slides over the picture.
When we browse major e-commerce websites, the most common dynamic effect of pictures should be the enlargement effect when the mouse moves into the picture or hovers over the picture. The main purpose of achieving such dynamic effects is to highlight product content and improve user experience. For code novices, this effect is certainly very attractive, but if you want to achieve it through html/css code, you may not know where to start. In fact, the code implementation is very simple. Below we will use a simple example to introduce to you the method of enlarging the image after the mouse passes.The html/css code example for the magnification effect of moving the mouse into the picture is as follows:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>html/Css3实现图片缩放</title>
<style type="text/css">
#div1{
width: 500px;
margin: 150px auto;
}
#div1 img{
transition: all 0.5s;
border-radius:5px;
border: #eee solid 2px;
}
#div1 img:hover{
transform: scale(1.5);
}
</style>
</head>
<body style="background: #000">
<div id="div1">
<img src="/static/imghwm/default1.png" data-src="123123.png" class="lazy" / alt="How to achieve the slow enlargement effect of images when hovering the mouse in css3? (image, text + video)" >
</div>
</body>
</html>First visit the front desk, and the picture effect is as shown below:


border-radius: to div Add a rounded border to the element.
:hover The selector is used to select the element on which the mouse pointer is floating.
transform : Applies a 2D or 3D transform to an element. This property allows us to rotate, scale, move or tilt the element. where, the value scale(x,y) Define the 2D scaling transformation. (This example sets the image zoom to 1.5 times)
transition: An abbreviated attribute used to set four transition attributes. (This example sets the transition time when the image is enlarged to 0.5 seconds to avoid the effect being too abrupt)
This article is about using html/css/css3 to achieve the effect of enlarging the image when the mouse passes over it. Very simple and easy to understand, I hope it will be helpful to friends in need! If you want to learn more about HTML/css, you can follow the PHP Chinese websiteHTML video tutorial and CSS video tutorial, CSS3 video tutorial , welcome everyone to refer to and study!
The above is the detailed content of How to achieve the slow enlargement effect of images when hovering the mouse in css3? (image, text + video). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor




