经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » CSS » 查看文章
CSS3变形透视动画-2 -cyy
来源:cnblogs  作者:陈莺莺呀  时间:2020/11/16 10:08:19  对本文有异议

网站动态logo制作:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6.  
  7. <style>
  8. *{
  9. margin:0;
  10. padding:0;
  11. box-sizing:border-box;
  12. }
  13. body{
  14. width:100vw;
  15. height:100vh;
  16. display:flex;
  17. justify-content:center;
  18. align-items:center;
  19. background:#ddd;
  20. }
  21. main div{
  22. cursor:pointer;
  23. font-size:2em;
  24. color:#333;
  25. }
  26. main div strong{
  27. display:inline-block; /*行元素不能旋转*/
  28. transition:1s;
  29. width:45px;
  30. height:45px;
  31. background:pink;
  32. border-radius:50%;
  33. text-align:center;
  34. }
  35. main div:hover strong:nth-child(1){
  36. transform:rotate(360deg);
  37. background:yellow;
  38. }
  39. main div:hover strong:nth-child(2){
  40. transform:rotate(-360deg);
  41. background:lightgreen;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <main>
  47. <div><strong>c</strong>y<strong>y</strong></div>
  48. </main>
  49. </body>
  50. </html>

 

 

 

 

倾斜语法介绍:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6.  
  7. <style>
  8. *{
  9. margin:0;
  10. padding:0;
  11. box-sizing:border-box;
  12. }
  13. main{
  14. width:400px;
  15. height:400px;
  16. border:1px solid silver;
  17. position:absolute;
  18. top:50%;
  19. left:50%;
  20. margin-top:-200px;
  21. margin-left:-200px;
  22. }
  23. div{
  24. width:200px;
  25. height:200px;
  26. position:absolute;
  27. top:50%;
  28. left:50%;
  29. margin-top:-100px;
  30. margin-left:-100px;
  31. }
  32. div:nth-child(1){
  33. background:pink;
  34. }
  35. div:nth-child(2){
  36. background:lightblue;
  37. transition:1s;
  38. }
  39. main:hover div:nth-child(2){
  40. transform:skewX(45deg);
  41. transform:skewY(45deg);
  42. transform:skew(45deg,-30deg);
  43. }
  44. </style>
  45. </head>
  46. <body>
  47. <main>
  48. <div></div>
  49. <div></div>
  50. </main>
  51. </body>
  52. </html>

 

 

使用skew制作炫酷按钮:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6.  
  7. <style>
  8. *{
  9. margin:0;
  10. padding:0;
  11. box-sizing:border-box;
  12. }
  13. body{
  14. width:100vw;
  15. height:100vh;
  16. display:flex;
  17. justify-content:center;
  18. align-items:center;
  19. background:gray;
  20. }
  21. main{
  22. width:200px;
  23. display:flex;
  24. justify-content:center;
  25. align-items:center;
  26. }
  27. main a{
  28. color:white;
  29. border:5px solid pink;
  30. padding:10px 50px;
  31. font-size:1.5em;
  32. color:white;
  33. text-decoration:none;
  34. position:relative;
  35. overflow:hidden;
  36. display:flex;
  37. justify-content:center;
  38. align-items:center;
  39. }
  40. .btn::after{
  41. content:'';
  42. position:absolute;
  43. width:0;
  44. height:100%;
  45. background:pink;
  46. transform:skew(45deg);
  47. transition:.3s;
  48. z-index:-1;
  49. }
  50. .btn:hover::after{
  51. width:200%;
  52. }
  53. </style>
  54. </head>
  55. <body>
  56. <main>
  57. <a href="" class="btn">按钮</a>
  58. </main>
  59. </body>
  60. </html>

 

快速制作3D立体按钮:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6.  
  7. <style>
  8. *{
  9. margin:0;
  10. padding:0;
  11. box-sizing:border-box;
  12. }
  13. body{
  14. width:100vw;
  15. height:100vh;
  16. display:flex;
  17. justify-content:center;
  18. align-items:center;
  19. background:gray;
  20. }
  21. .btn{
  22. color:white;
  23. background:pink;
  24. width:300px;
  25. height:50px;
  26. font-size:1em;
  27. color:white;
  28. text-decoration:none;
  29. position:relative;
  30. display:flex;
  31. justify-content:center;
  32. align-items:center;
  33. transform:skewX(25deg) rotate(-15deg);
  34. letter-spacing:.5em;
  35. text-transform:uppercase;
  36. }
  37. .btn::before{
  38. content:'';
  39. position:absolute;
  40. width:10px;
  41. height:100%;
  42. background:#000;
  43. transition:.3s;
  44. left:-10px;
  45. transform:skewY(-45deg) translateY(5px);
  46. }
  47. .btn::after{
  48. content:'';
  49. position:absolute;
  50. width:100%;
  51. height:10px;
  52. background:#000;
  53. transition:.3s;
  54. bottom:-10px;
  55. transform:skewX(-45deg) translateX(-5px);
  56. }
  57. </style>
  58. </head>
  59. <body>
  60. <a href="" class="btn">按钮</a>
  61. </body>
  62. </html>

 

 

2D变形参考点使用:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6.  
  7. <style>
  8. *{
  9. margin:0;
  10. padding:0;
  11. box-sizing:border-box;
  12. }
  13. main{
  14. width:400px;
  15. height:400px;
  16. border:1px solid silver;
  17. position:absolute;
  18. top:50%;
  19. left:50%;
  20. margin-top:-200px;
  21. margin-left:-200px;
  22. }
  23. div{
  24. width:200px;
  25. height:200px;
  26. position:absolute;
  27. top:50%;
  28. left:50%;
  29. margin-top:-100px;
  30. margin-left:-100px;
  31. transform-origin:center center;
  32. transform-origin:left top;
  33. transform-origin:right bottom;
  34. transform-origin:left center;
  35. transform-origin:0 0;
  36. transform-origin:200% 200%;
  37. transform-origin:left bottom;
  38. }
  39. div:nth-child(1){
  40. background:pink;
  41. }
  42. div:nth-child(2){
  43. background:lightblue;
  44. transition:1s;
  45. }
  46. main:hover div:nth-child(2){
  47. transform:rotate(145deg);
  48. transform:skew(-45deg);
  49. }
  50. </style>
  51. </head>
  52. <body>
  53. <main>
  54. <div></div>
  55. <div></div>
  56. </main>
  57. </body>
  58. </html>

 

 

3D变形参考点:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6.  
  7. <style>
  8. *{
  9. margin:0;
  10. padding:0;
  11. box-sizing:border-box;
  12. }
  13. main{
  14. width:400px;
  15. height:400px;
  16. border:1px solid silver;
  17. position:absolute;
  18. top:50%;
  19. left:50%;
  20. margin-top:-200px;
  21. margin-left:-200px;
  22. /* 透视加在父容器上 */
  23. transform-style:preserve-3d;
  24. transform:perspective(900px) rotateY(45deg) rotateX(45deg);
  25. }
  26. div{
  27. width:200px;
  28. height:200px;
  29. position:absolute;
  30. top:50%;
  31. left:50%;
  32. margin-top:-100px;
  33. margin-left:-100px;
  34. transform-origin:center center;
  35. transform-origin:left top;
  36. transform-origin:right bottom;
  37. transform-origin:right bottom 100px;
  38. }
  39. div:nth-child(1){
  40. background:pink;
  41. }
  42. div:nth-child(2){
  43. background:lightblue;
  44. transition:1s;
  45. }
  46. main:hover div:nth-child(2){
  47. transform:rotateY(145deg);
  48. /* transform:skew(-45deg); */
  49. }
  50. </style>
  51. </head>
  52. <body>
  53. <main>
  54. <div></div>
  55. <div></div>
  56. </main>
  57. </body>
  58. </html>

 

 

 

3D新年快乐贺卡制作:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6.  
  7. <style>
  8. *{
  9. margin:0;
  10. padding:0;
  11. box-sizing:border-box;
  12. }
  13. body{
  14. width:100vw;
  15. height:100vh;
  16. display:flex;
  17. justify-content:center;
  18. align-items:center;
  19. background:#ddd;
  20. }
  21. .card{
  22. width:300px;
  23. height:200px;
  24. display:flex;
  25. justify-content:center;
  26. align-items:center;
  27. background:pink;
  28. color:#555;
  29. position:relative;
  30. transform-style:preserve-3d;
  31. transform:perspective(900px) rotateX(45deg);
  32.  
  33. }
  34. .card::before,.card::after{
  35. position:absolute;
  36. width:50%;
  37. height:100%;
  38. background:lightblue;
  39. transition:1s;
  40. box-sizing:border-box;
  41. }
  42. .card::before{
  43. content:'生日';
  44. left:0;
  45. top:0;
  46. display:flex;
  47. justify-content:flex-end;
  48. align-items:center;
  49. transform-origin:left;
  50. border-right:2px solid #333;
  51. padding-right:2px;
  52. }
  53. .card::after{
  54. content:'快乐';
  55. right:0;
  56. top:0;
  57. display:flex;
  58. justify-content:flex-start;
  59. align-items:center;
  60. transform-origin:right;
  61. border-left:2px solid #333;
  62. padding-left:2px;
  63. }
  64. .card:hover::before{
  65. transform:rotateY(-180deg);
  66. }
  67. .card:hover::after{
  68. transform:rotateY(180deg);
  69. }
  70. </style>
  71. </head>
  72. <body>
  73. <div class="card">美少女cyy</div>
  74. </body>
  75. </html>

 

纯css3电子时钟绘制表盘:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6.  
  7. <style>
  8. *{
  9. margin:0;
  10. padding:0;
  11. box-sizing:border-box;
  12. }
  13. body{
  14. width:100vw;
  15. height:100vh;
  16. display:flex;
  17. justify-content:center;
  18. align-items:center;
  19. background:#01547a;
  20. }
  21. main{
  22. width:400px;
  23. height:400px;
  24. border-radius:50%;
  25. position:relative;
  26. }
  27. .clock{
  28. width:400px;
  29. height:400px;
  30. border-radius:50%;
  31. background-image:linear-gradient(to right,#ffeb3b,#ff9800,#ff5722);
  32. position:relative;
  33. z-index:-2;
  34. }
  35. .clock::after{
  36. content:'';
  37. position:absolute;
  38. width:90%;
  39. height:90%;
  40. left:50%;
  41. top:50%;
  42. transform:translate(-50%,-50%);
  43. background:#01547a;
  44. border-radius:50%;
  45. z-index:-1;
  46. }
  47. .line{
  48. width:80%;
  49. height:80%;
  50. left:50%;
  51. top:50%;
  52. transform:translate(-50%,-50%);
  53. position:absolute;
  54. /* background:black; */
  55. border-radius:50%;
  56. }
  57. .line::before{
  58. content:'';
  59. width:90%;
  60. height:90%;
  61. background:#01547a;
  62. position:absolute;
  63. left:50%;
  64. top:50%;
  65. transform:translate(-50%,-50%);
  66. border-radius:50%;
  67. z-index:2;
  68. }
  69. .line::after{
  70. content:'';
  71. width:20px;
  72. height:20px;
  73. background:white;
  74. position:absolute;
  75. left:50%;
  76. top:50%;
  77. transform:translate(-50%,-50%);
  78. border-radius:50%;
  79. z-index:2;
  80. }
  81. .line>div{
  82. width:8px;
  83. height:100%;
  84. position:absolute;
  85. background:white;
  86. left:50%;
  87. transform:translateX(-50%);
  88. }
  89. .line>div:nth-child(1){
  90. transform:translateX(-50%) rotate(30deg);
  91. }
  92. .line>div:nth-child(2){
  93. transform:translateX(-50%) rotate(60deg);
  94. }
  95. .line>div:nth-child(3){
  96. transform:translateX(-50%) rotate(90deg);
  97. }
  98. .line>div:nth-child(4){
  99. transform:translateX(-50%) rotate(120deg);
  100. }
  101. .line>div:nth-child(5){
  102. transform:translateX(-50%) rotate(150deg);
  103. }
  104. .line>div:nth-child(6){
  105. transform:translateX(-50%) rotate(180deg);
  106. }
  107. .hour{
  108. width:8px;
  109. height:15%;
  110. bottom:50%;
  111. position:absolute;
  112. background:white;
  113. left:50%;
  114. transform:translateX(-50%);
  115. transform-origin:bottom;
  116. transition:10s;
  117. }
  118. .minutes{
  119. width:5px;
  120. height:25%;
  121. bottom:50%;
  122. position:absolute;
  123. background:white;
  124. left:50%;
  125. transform:translateX(-50%) rotate(60deg);
  126. transform-origin:bottom;
  127. transition:10s;
  128. }
  129. .seconds{
  130. width: 1px;
  131. height:35%;
  132. bottom:50%;
  133. position:absolute;
  134. background:white;
  135. left:50%;
  136. transform:translateX(-50%) rotate(120deg);
  137. transform-origin:bottom;
  138. transition:10s;
  139. }
  140. main:hover .seconds{
  141. transform:translateX(-50%) rotate(360deg);
  142. }
  143. </style>
  144. </head>
  145. <body>
  146. <main>
  147. <div class="clock">
  148. <div class="line">
  149. <div></div>
  150. <div></div>
  151. <div></div>
  152. <div></div>
  153. <div></div>
  154. <div></div>
  155. </div>
  156. <div class="hour"></div>
  157. <div class="minutes"></div>
  158. <div class="seconds"></div>
  159. </div>
  160. </main>
  161. </body>
  162. </html>

 

transform-origin技术做动态旋转菜单:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
  7.  
  8. <style>
  9. *{
  10. margin:0;
  11. padding:0;
  12. box-sizing:border-box;
  13. list-style:none;
  14. }
  15. body{
  16. width:100vw;
  17. height:100vh;
  18. display:flex;
  19. justify-content:center;
  20. align-items:center;
  21. background:#01547a;
  22. }
  23. nav{
  24. width:200px;
  25. height:200px;
  26. background:#ff9800;
  27. border-radius:50%;
  28. position:relative;
  29. display:flex;
  30. justify-content:center;
  31. align-items:center;
  32. cursor:pointer;
  33. }
  34. nav::after{
  35. content:'cyy';
  36. font-size:3em;
  37. color:white;
  38. }
  39. nav:hover ul{
  40. transform:translate(-50%,-50%) scale(1);
  41. }
  42. ul{
  43. transition:.5s;
  44. width:300px;
  45. height:300px;
  46. /* border:1px solid black; */
  47. position:absolute;
  48. left:50%;
  49. top:50%;
  50. transform:translate(-50%,-50%) scale(0);
  51. }
  52. li{
  53. width:80px;
  54. height:80px;
  55. background:#ff9800;
  56. border-radius:50%;
  57. position:absolute;
  58. display:flex;
  59. justify-content:center;
  60. align-items:center;
  61. color:white;
  62. font-size:2em;
  63. transition:1s;
  64. transform-origin:150px 150px;
  65.  
  66. }
  67. ul:hover li:nth-child(1){
  68. transform:rotate(40deg);
  69. }
  70. ul:hover li:nth-child(1) span{
  71. transform:rotate(320deg);
  72. }
  73. ul:hover li:nth-child(2){
  74. transform:rotate(80deg);
  75. }
  76. ul:hover li:nth-child(2) span{
  77. transform:rotate(640deg);
  78. }
  79. ul:hover li:nth-child(3){
  80. transform:rotate(120deg);
  81. }
  82. ul:hover li:nth-child(3) span{
  83. transform:rotate(960deg);
  84. }
  85. ul:hover li:nth-child(4){
  86. transform:rotate(160deg);
  87. }
  88. ul:hover li:nth-child(4) span{
  89. transform:rotate(1280deg);
  90. }
  91. ul:hover li:nth-child(5){
  92. transform:rotate(200deg);
  93. }
  94. ul:hover li:nth-child(5) span{
  95. transform:rotate(1600deg);
  96. }
  97. ul:hover li:nth-child(6){
  98. transform:rotate(240deg);
  99. }
  100. ul:hover li:nth-child(6) span{
  101. transform:rotate(1920deg);
  102. }
  103. ul:hover li:nth-child(7){
  104. transform:rotate(280deg);
  105. }
  106. ul:hover li:nth-child(7) span{
  107. transform:rotate(2240deg);
  108. }
  109. ul:hover li:nth-child(8){
  110. transform:rotate(320deg);
  111. }
  112. ul:hover li:nth-child(8) span{
  113. transform:rotate(2560deg);
  114. }
  115. ul:hover li:nth-child(9){
  116. transform:rotate(360deg);
  117. }
  118. ul:hover li:nth-child(9) span{
  119. transform:rotate(3240deg);
  120. }
  121.  
  122. </style>
  123. </head>
  124. <body>
  125. <nav>
  126. <ul>
  127. <li><span></span></li>
  128. <li><span><i class="fa fa-h-square" aria-hidden="true"></i></span></li>
  129. <li><span><i class="fa fa-address-book" aria-hidden="true"></i></span></li>
  130. <li><span></span></li>
  131. <li><span><i class="fa fa-calculator" aria-hidden="true"></i></span></li>
  132. <li><span><i class="fa fa-dashcube" aria-hidden="true"></i></span></li>
  133. <li><span></span></li>
  134. <li><span><i class="fa fa-eercast" aria-hidden="true"></i></span></li>
  135. <li><span><i class="fa fa-h-square" aria-hidden="true"></i></span></li>
  136. </ul>
  137. </nav>
  138. </body>
  139. </html>

原文链接:http://www.cnblogs.com/chenyingying0/p/13956622.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号