如果要使得你的3D轉(zhuǎn)換效果更加容易觀察逗嫡,可以給要變換的父元素加上perspective屬性(必須加在父元素上育瓜,和transform-style:preserve-3D一樣)葫隙,使得效果更加明顯
此時對應(yīng)代碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
}
img{
}
</style>
</head>
<body>
<div>
<img src="images/xx.jpg">
</div>
</body>
</html>
此時對應(yīng)代碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
}
img{
transform: rotateX(30deg);
}
</style>
</head>
<body>
<div>
<img src="images/xx.jpg">
</div>
</body>
</html>
此時對應(yīng)代碼為
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
perspective: 600px;
}
img{
transform: rotateX(30deg);
}
</style>
</head>
<body>
<div>
<img src="images/xx.jpg">
</div>
</body>
</html>
我寫了一些3D轉(zhuǎn)換的小例子,放在了我的github上 https://github.com/lionlsc/rotate3D