赞
踩
- <style type="text/css">
- @font-face {
- font-family: name; /* 定义字体名称 */
- src: url(fonts/mc.ttf); /* 定义字体来源 */
- }
- p{
- font-family: name; /* 引用自定义字体名称 */
- }
- </style>
2D转换方法:对元素进行旋转、缩放、移动、拉伸 。
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- <style type="text/css">
- #t{
- border: 1px solid black;
- width: 300px;
- height: 300px;
- margin: 0 auto;
- }
- #right{
- margin: 15px auto;
- border: 1px solid black;
- width: 150px;
- height: 100px;
- text-align: center;
- line-height: 100px;
- transform: rotate(30deg); /* 顺时针旋转30度 */
- }
- #left{
- margin: 15px auto;
- border: 1px solid black;
- width: 150px;
- height: 100px;
- text-align: center;
- line-height: 100px;
- transform: rotate(-30deg); /* 逆时针旋转30度 */
- }
- #left:hover{
- transform: scale(1.5); /* 放大1.5倍 */
- }
- </style>
- </head>
- <body bgcolor="white">
- <div id="t">
- <div id="right">旋转与缩放</div>
- <div id="left">旋转与缩放</div>
- </div>
- </body>
- </html>
transition: 属性名 持续时间 过渡方法;属性名多个时用“ ,”隔开,或用all表示所有属性。
值 | 描述 |
animation | 简写 |
animation-name | 引用@keyframes动画的名称 |
animation-duration | 动画完成时间 |
animation-timing-function | 规定动画的速度曲线。默认是“ease” |
animation-play-state | running | paused |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- <style type="text/css">
- @keyframes wdcolor /* 动画名称 */
- {
- 0% {background-color:red; color: blue;}
- 30% {background-color:blue; color: red;}
- 60% {background-color:yellow; color: green;}
- 100% {background-color:green; color: yellow;}
- }
- #s:hover{
- animation: wdcolor 5s linear;
- }
- #s{
- margin-top: 50px;
- width: 300px;
- height: 200px;
- text-align: center;
- line-height: 200px;
- font-size: 25px;
- font-weight:bold;
- border: 1px solid white;
- background-color: black;
- color: white;
- }
- </style>
- </head>
- <body bgcolor="white">
-
- <div id="s">
- 动画效果
- </div>
- </body>
- </html>
transform属性:
延X轴方向旋转:rotateX( deg)
延Y轴方向旋转:rotateY( deg):
延Z轴方向旋转:rotateZ( deg):
透视属性:perspective;
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- <style type="text/css">
- #r{
- width: 1200px;
- border: 1px solid blue;
- height: 700px;
- margin: 10px auto;
- perspective: 800px;
- }
- img{
- width: 300px;
- height:500px;
- }
- #x,#y,#z{
- width: 302px;
- height: 502px;
- float: left;
- margin-left: 40px;
- margin-top: 100px;
- transition: linear 1s;
- transform-style: preserve-3d;
- border: 1px solid blue;
- }
- #x:hover{
- transform: rotateX(30deg);
- }
- #y:hover{
- transform: rotateY(180deg);
- }
- #z:hover{
- transform: rotateZ(60deg);
- }
- </style>
- </head>
- <body bgcolor="white">
- <div id="r">
- <div id="x">
- <img src="picture/45.png" />
- </div>
- <div id="y">
- <img src="picture/45.png "/>
- </div>
- <div id="z">
- <img src="picture/45.png "/>
- </div>
- </div>
- </body>
- </html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。