移动端初级知识点解析:translateZ translateY rotateY(上上上)

2020-10-28 10:30:34 浏览数 (1)

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<style type="text/css">
		*{padding: 0px;margin: 0px;}
		div
		{
			width: 200px;height: 200px;background: black;
			position: absolute;left: 50%;top: 50%;margin: 100px 0 0 -200px;
			transition: 5s;			

		}
		div img
		{
			width: 100%;height: 100%;float: left;

		}
		div:hover
		{
			transform: rotateY(180deg);
		}
	</style>
</head>
<body>
	<div><img src="21312.jpg"></div>
</body>
</html>

核心;transition: 5s;放在div里面就会怎么过来怎么回来。放再:hover就会怎么过去,一瞬间回来。

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<style type="text/css">
		*{margin: 0;padding:0;list-style: none;}
		div
		{
			width: 200px;height: 200px;background: black;float: left;transition: 1s;
		}
		div img
		{
			width: 100%;height: 100%;float: left;
		}
		#div1:hover
		{
			transform: translateY(-230px);
		}
	</style>
</head>
<body>
	<div id="div1"><img src="21312.jpg"></div>
<div></div>
</body>
</html>
代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<style type="text/css">
		*{margin: 0;padding:0;list-style: none;}
		#div1
		{
			width: 200px;height: 200px;background: black;float: left;transition: 5s;position: absolute;left: 50%;top: 50%;margin: -100px 0 0 -100px;
			transform-style: preserve-3d;

		}
		#div1:hover
		{
			transform:perspective(100px)  rotateY(80deg);
		}
		#div1>div
		{
			width: 100%;height: 100%;background: yellow;position: absolute;transform: translateZ(-90px);
		}
	</style>
</head>
<body>
	<div id='div1'>
	<div></div>
</div>
</body>
</html>

0 人点赞