首页 > 代码库 > css3 景深

css3 景深

<!DOCTYPE html>
<html>
<head>
<title>景深</title>
<style type="text/css">
.box{
width: 400px;
height: 400px;
margin: 100px auto;
position: relative;
transform-style: preserve-3d;
/*景深相当于眼睛距离元素的位置距离*/
perspective: 100px;
/*眼睛距元素的偏移位置*/
perspective-origin: 10px 100px;
}
img:nth-child(1){
width: 400px;
height: 400px;
opacity: 0;
}
img:nth-child(2){
width: 150px;
height: 200px;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
opacity: 0;
}
img:nth-child(3){
width: 150px;
height: 200px;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
transform: rotateX(30deg);
}
</style>
</head>
<body>
<div class="box">
<img src="http://www.mamicode.com/img/bg-grid.jpg">
<img src="http://www.mamicode.com/img/cardKingClub.png">
<img src="http://www.mamicode.com/img/dameizi.jpeg">
</div>
</body>
</html>

css3 景深