3D转换加上透视效果

来源:互联网 发布:stm32用什么软件编程 编辑:程序博客网 时间:2024/06/03 22:49

CSS3的3D转换加上透视效果。

截图:



代码:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>3D转换练习</title>
<style type="text/css">
div{
width: 120px;
height: 120px;
border: solid 1px #000;
margin: 50px auto;
perspective: 400px;/*透视的效果,必须给父元素加*/
}
/*图片3D变化*/
div:hover img{
transform: rotateX(60deg);/*X轴旋转60度*/
transition: all 0.5s;
}
#table1{
width: 300px;
height: 300px;
margin: 30px auto;
background-color: black;
perspective: 500px;/*透视的效果,必须给父元素加*/
}
table{
margin: 30px auto;
}
/*图片3D变化*/
#table1:hover table{
transform: rotateX(40deg);/*X轴旋转60度*/
transition: all 0.5s;
}
</style>
</head>


<body>
<div><img src="images\userHead.jpg"></div>
<div id="table1">
<table width="300" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <th scope="col">&nbsp;</th>
    <th scope="col">&nbsp;</th>
    <th scope="col">&nbsp;</th>
    <th scope="col">&nbsp;</th>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</div>
</body>
</html>

0 0
原创粉丝点击