css to achieve dynamic effects of mouse movement in and out

不言
Release: 2018-05-03 14:38:17
Original
8930 people have browsed it

This article mainly introduces the dynamic effect of moving the mouse in and out using css. It has certain reference value. Now I share it with you. Friends in need can refer to it.

Knowledge point: transform-origin

Compatibility: IE10 or above

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<style>
			p {


			    position: absolute;
			
			    width: 200px;
			
			    height: 60px;
			    text-align: center;
			    margin: 10px auto;
			
			}
			p::before {
			
			    content: "";
			
			    position: absolute;
			
			    left: 0;
			
			    bottom: 0;
			
			    width: 200px;
			
			    height: 2px;
			
			    background: deeppink;
			
			    transition: transform .5s;
			
			    transform: scaleX(0);
			
			    transform-origin: 100% 0;//以(100%,0)坐标为基本点移动即缩小到0倍---->scaleX(0)
			
			}
			p:hover::before {
			
			    transform: scaleX(1);
			
			    transform-origin: 0 0;//以(0,0)坐标为基本点移动即放大到1倍---->scaleX(1)
			
			}
		</style>
	</head>
	<body>
		<p>Hover Me</p>
	</body>
</html>
Copy after login

Related recommendations:

Pure css to realize gradual highlighting when the mouse moves in

The above is the detailed content of css to achieve dynamic effects of mouse movement in and out. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template