3_旋转.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. .box{
  9. width: 200px;
  10. height: 200px;
  11. background-color: red;
  12. margin: 200px auto;
  13. text-align: center;
  14. line-height: 200px;
  15. color: #fff;
  16. font-size: 100px;
  17. font-weight: bold;
  18. /* rotate() 旋转变换 有一个参数 用于指定元素旋转的角度
  19. 正数顺时针旋转 负数逆时针旋转
  20. */
  21. /* transform: rotate(45deg); */
  22. /* 原点 transform-origin 用于指定元素旋转的中心点 */
  23. /* 默认值是元素的中心点 */
  24. /* transform-origin有两个值 分别是水平方向和垂直方向的原点 */
  25. /* 可以使用 top left right bottom 也可以使用百分比 、像素值 */
  26. /* 原点可以在元素外部 */
  27. transform-origin: center 500px;
  28. transform: rotate(45deg);
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div class="box">
  34. </div>
  35. </body>
  36. </html>