Why is the title of the article “Imitation Magnifying Glass”? Okay, let’s get back to the topic. What I want to talk about today is the animation of enlarging the picture at its original location when the mouse moves in ! The first thing that came to mind was the @keyframes attribute of CSS3, because it is used more often. For example: You can achieve this through transition ( today's focus ) Prophet: CSS3 attribute transform——(rotate: rotate, scale: scale, skew: skew, translate: translate) For example: Doesn’t it look very stiff? Let's take a look at the effect of adding transition: After looking at the difference between the two effects, you probably understand the role of the transition attribute. The goal of this example is similar to the width change, but the final effect is changed. Please continue to look at the detailed code below: <div id="container"> <img src="./little_boy.jpg" /> <span>Hello everyone! Who am I? </span> </div> #container { margin: 200px; position: relative; width: 300px; height: 300px; background-color: greenyellow; transition: transform .5s ease-out; } #container img { width: 100%; height: 100%; } #container span { position: absolute; top: 0; left: 0; margin: 6px; width: 100%; height: 20px; line-height: 20px; font-size: 18px; color: white; text-align: center; } #container:hover { transform: scale(1.3); } Analysis: This concludes this article about the principles and analysis of several ways to simulate a magnifying glass effect in CSS3. For more relevant CSS3 magnifying glass content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: Summary of commonly used tags in HTML (must read)
>>: Specific use of MySQL window functions
Around version 0.6, privileged was introduced to ...
I struggled with this for a long time, and after s...
Table of contents 1. Block scope 1.1. let replace...
When we package the webpackjs file, we introduce ...
Table of contents When setting up a MySQL master-...
Tips: Array change method will cause v-for to upd...
Everyone knows that data in MySQL needs to be wri...
This article example shares the specific code for...
1. Introduction Recently, I helped a friend to ma...
introduction You must have encountered this in an...
Table of contents mapState mapGetters mapMutation...
remember: IDE disk: the first disk is hda, the se...
We simply need to open any text editor, copy the f...
Table of contents Introduction Mirror repository ...
Table of contents Preface text parameter example ...