1. 公共样式的提取

2.css2d转换

  1. transform:translate(x,y) rotate(30deg)
  2. //位移
  3. translate(x,y)
  4. //旋转
  5. rotate()
  6. //缩放
  7. scale(x,y)
  8. //倾斜
  9. skew(x,y)
  10. 配合transform属性使用

2.1translate位移

该元素移动的位置,取决于宽度(X轴)和高度(Y)

  1. translate(x,y) x横坐标方向移动的距离,y纵坐标方向移动的距离div#div2
  2. {
  3. transform:translate(50px,100px);
  4. -ms-transform:translate(50px,100px); /* IE 9 */
  5. -webkit-transform:translate(50px,100px); /* Safari and Chrome */
  6. }
  1. 再说垂直水平居中
  2. <div class="one">
  3. <div class="two">
  4. </div>
  5. </div>
  6. .one{
  7. width:400px;
  8. height:400px;
  9. background-color: red;
  10. position: relative;
  11. }
  12. .two{
  13. width:100px;
  14. height:100px;
  15. background-color: pink;
  16. position: absolute;
  17. margin:auto;
  18. left:0;
  19. top:0;
  20. bottom:0;
  21. right:0;
  22. }

2.2旋转rotate

  1. div
  2. {
  3. transform: rotate(30deg);
  4. -ms-transform: rotate(30deg); /* IE 9 */
  5. -webkit-transform: rotate(30deg); /* Safari and Chrome */
  6. }

2.3缩放scale()方法,该元素增加或减少的大小,取决于宽度(X轴)和高度(Y轴)的参数

  1. //scale(2,3)转变宽度为原来的大小的2倍,和其原始大小3倍的高度。
  2. -ms-transform:scale(2,3); /* IE 9 */
  3. -webkit-transform: scale(2,3); /* Safari */
  4. transform: scale(2,3); /* 标准语法 */

2.4倾斜skew(x,y) 方法

  1. x表示水平方向,y表示垂直方向
  2. div
  3. {
  4. transform: skew(30deg,20deg);
  5. -ms-transform: skew(30deg,20deg); /* IE 9 */
  6. -webkit-transform: skew(30deg,20deg); /* Safari and Chrome */
  7. }

3.transition过渡

  1. CSS3 过渡(transition) 配合hover使用
  2. //改变宽度时长为2秒
  3. div
  4. {
  5. transition: width 2s;
  6. -webkit-transition: width 2s; /* Safari */
  7. }
  8. div:hover{
  9. width:100px;
  10. }
  11. 多项改变
  12. div
  13. {
  14. transition: width 2s, height 2s, transform 2s;
  15. // transition: all 2s;
  16. -webkit-transition: width 2s, height 2s, -webkit-transform 2s;
  17. }
  18. div:hover{
  19. width:200px;
  20. height:200px;
  21. transform:rotate(30deg)
  22. }

4.animation动画

  1. 动画animation
  2. 1.定义@keyframes
  3. A.@keyframes myfirst
  4. {
  5. from {background: red;}
  6. to {background: yellow;}
  7. }
  8. B.@keyframes myfirst
  9. {
  10. 0% {background: red;}
  11. 25% {background: yellow;}
  12. 50% {background: blue;}
  13. 100% {background: green;}
  14. }
  15. div{
  16. animation:myfirst 2s;
  17. }
  18. div{
  19. animation:myfirst 2s infinite; //无限循环
  20. }

5.iconfont的使用

  1. http://www.iconfont.cn/

6.animate.css的使用

  1. https://github.com/daneden/animate.css