3D移动translate3d
<html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>3D移动translate3d
title> <style> body {
/* 透视写在被观察元素的父盒子上 */ /* 透视越小,成像越大 */ /* perspective: 200px; */ perspective: 500px; } div {
width: 200px; height: 200px; background-color: pink; /* 以下写法会出现样式层叠的情况,不能这样写 */ /* transform: translateX(100px); transform: translateY(100px); */ /* 正确写法 */ /* transform: translateX(100px) translateY(100px) translateZ(100px); */ /* 1.translateZ(100px) 向外移动 也就是向我们的眼睛来移动的 */ /* 简写方式 */ /* transform: translate3d(x, y, z); */ /* transform: translate3d(100px, 100px, 100px); */ /* 2.xyz是不能省略的,如果没有就写0 */ transform: translate3d(400px, 100px, 100px); }
style>
head> <body> <div>
div>
body>
html>
02-translateZ
<html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>translateZ
title> <style> body {
perspective: 500px; } div {
width: 200px; height: 200px; background-color: pink; margin: 100px auto; transform: translateZ(0); }
style>
head> <body> <div>
div>
body>
html>
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/224991.html原文链接:https://javaforall.net
