css简单样式(旋转正方形、纸片旋转、轮播图3D、简单轮播图)

2021-6-10    前端达人

 
  1. 旋转正方形
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <meta charset="utf-8">
  7. <title>旋转立方体</title>
  8. <style type="text/css">
  9. .stage{
  10. position: relative;
  11. perspective: 800px;
  12. }
  13. @keyframes rotate-frame{ /* 设置动画效果 */
  14. 0% {
  15. transform: rotateX(0deg) rotateY(0deg);
  16. }
  17. 50% {
  18. transform: rotateX(360deg) rotateY(0deg);
  19. }
  20. 100% {
  21. transform: rotateX(360deg) rotateY(360deg);
  22. }
  23. }
  24. .container{
  25. width: 450px;
  26. height: 450px;
  27. margin: 0 auto;
  28. transform-style:preserve-3d;
  29. animation: rotate-frame 8s infinite linear;
  30. animation-timing-function: all;
  31. animation-direction: normal;
  32. animation-fill-mode: backwards;
  33. transform-origin: 50% 50% 75px;
  34. /*background: yellow; 容器屏幕背景色*/
  35. }
  36. .container:hover{
  37. /*覆盖时暂停动画*/
  38. animation-play-state: paused;
  39. }
  40. .side{
  41. width: 150px;
  42. height: 150px;
  43. position: absolute;
  44. text-align: center;
  45. line-height: 150px;
  46. font-size: 50px;
  47. }
  48. .top{
  49. left: 150px;
  50. top: 0;
  51. transform: rotateX(-90deg); /* 设置角度 */
  52. transform-origin: bottom;
  53. background-color: rgba(0,0,255,0.5);
  54. }
  55. .bottom{
  56. left: 150px;
  57. top: 300px;
  58. transform: rotateX(90deg);
  59. transform-origin: top;
  60. background-color: rgba(0,255,0,0.5);
  61. }
  62. .left{
  63. left: 0;
  64. top: 150px;
  65. transform: rotateY(90deg);
  66. transform-origin: right;
  67. background-color: rgba(255,0,0,0.5);
  68. }
  69. .right{
  70. left: 300px;
  71. top: 150px;
  72. transform: rotateY(-90deg);
  73. transform-origin: left;
  74. background-color: rgba(0,0,100,0.5);
  75. }
  76. .front{
  77. left: 150px;
  78. top: 150px;
  79. transform: translateZ(150px);
  80. background-color: rgba(0,100,0,0.5);
  81. }
  82. .back{
  83. left: 150px;
  84. top: 150px;
  85. background-color: rgba(100,0,0,0.5);
  86. }
  87. .rotateX180{
  88. /*让倒置的数字倒置回正常状态*/
  89. transform: rotateX(180deg);
  90. }
  91. </style>
  92. </head>
  93. <body>
  94. <div class="stage">
  95. <div class="container">
  96. <div class="side top" >1</div>
  97. <div class="side bottom">2</div>
  98. <div class="side left">3</div>
  99. <div class="side right">4</div>
  100. <div class="side front">5</div>
  101. <div class="side back">6</div>
  102. </div>
  103. </div>
  104. </body>
  105. </html>
 
  1. 纸片旋转
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>Document</title>
  7. <style type="text/css">
  8. .zpbox{
  9. /*设置3D视角*/
  10. perspective: 800px;
  11. perspective-origin: bottom right;
  12. }
  13. .box{
  14. height: 200px;
  15. width: 100px;
  16. margin: 50px auto;
  17. /*preserve-3d 指定子元素定位在三维空间内 */
  18. transform-style: preserve-3d;
  19. /*指定变换为:linear-线性过渡*/
  20. transition-timing-function:linear;
  21. /*指定旋转动画*/
  22. animation-name: action_b1;
  23. animation-duration: 4s;
  24. animation-timing-function: all;
  25. animation-direction: normal;
  26. animation-iteration-count: infinite;
  27. animation-fill-mode: backwards;
  28. position: relative;
  29. }
  30. .box:hover{
  31. /*覆盖时暂停动画*/
  32. animation-play-state: paused;
  33. }
  34. .b1{
  35. /*声明第一个卡片为浮动,使得两个卡片能重叠*/
  36. float: left;
  37. height: 200px;
  38. width: 100px;
  39. background-color: #000;
  40. text-align:center;
  41. line-height: 100px;
  42. color: #fff;
  43. font-size:50px;
  44. }
  45. .b2{
  46. height: 200px;
  47. width: 100px;
  48. background-color: #000;
  49. text-align:center;
  50. line-height: 100px;
  51. color: #fff;
  52. font-size:50px;
  53. /*第二个卡片旋转90度*/
  54. transform: rotateX(90deg);
  55. /*第二个卡片位于中间位置*/
  56. position: absolute;
  57. margin-left: 0;
  58. margin-top: 0;
  59. }
  60. .rotateX180{
  61. /*让倒置的2、4数字倒置回正常状态*/
  62. transform: rotateX(180deg);
  63. }
  64. @keyframes action_b1{
  65. 100%{
  66. transform: rotateX(-360deg);
  67. }
  68. }
  69. </style>
  70. </head>
  71. <body>
  72. <div class="zpbox">
  73. <div class="box">
  74. <div class="b1">
  75. <div>1</div>
  76. <div class="rotateX180">3</div>
  77. </div>
  78. <div class="b2">
  79. <div>2</div>
  80. <div class="rotateX180">4</div>
  81. </div>
  82. </div>
  83. </div>
  84. </body>
  85. </html>
 
  1. 轮播图3D
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>Document</title>
  7. <style type="text/css">
  8. html, body, ul, li, ol, dl, dd, dt, p, h1, h2, h3, h4, h5, h6, form, fieldset, legend, img { margin:0; padding:0; } /*去掉多余的像素*/
  9. body{
  10. perspective: 800px;
  11. }
  12. .box{
  13. width: 800px;
  14. height: 360px;
  15. margin: 100px auto;
  16. text-align:center;
  17. position: relative;
  18. left: 50%;
  19. margin-left: -400px;
  20. /*background-color: #eee;*/
  21. transform-style: preserve-3d; /*设置为3D模式*/
  22. /*transform: rotateY(-30deg) rotateX(57deg);*/
  23. /*transition:5s ease;*/
  24. animation-name: animate;
  25. animation-duration: 10s;
  26. animation-iteration-count: infinite;
  27. }
  28. .box>div{
  29. width: 800px;
  30. height: 360px;
  31. position: absolute;
  32. }
  33. .box>.up{
  34. background: url(flower.jpg); /*引入照片*/
  35. transform: rotateX(90deg) translateZ(180px); /* 设置角度 */
  36. }
  37. .box>.down{
  38. background: url(flower.jpg);
  39. transform: rotateX(90deg) rotateZ(180deg)translateZ(-180px);
  40. }
  41. .box>.before{
  42. background: url(flower.jpg);
  43. transform: translateZ(180px);
  44. }
  45. .box>.after{
  46. background: url(flower.jpg);
  47. transform: translateZ(-180px) rotateX(180deg);
  48. }
  49. .box:hover{
  50. animation-play-state: paused; /* 当鼠标悬停的时候停止 */
  51. }
  52. @keyframes animate{
  53. 0%{
  54. }
  55. 25%{
  56. transform: rotateX(90deg);
  57. }
  58. 50%{
  59. transform: rotateX(180deg);
  60. }
  61. 75%{
  62. transform: rotateX(270deg);
  63. }
  64. 100%{
  65. transform: rotateX(360deg);
  66. }
  67. </style>
  68. </head>
  69. <body>
  70. <div class="box">
  71. <div class="up"></div>
  72. <div class="down"></div>
  73. <div class="before"></div>
  74. <div class="after"></div>
  75. </div>
  76. </body>
  77. </html>
  
  1. 轮播
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>轮播</title>
  7. <style>
  8. .frame{
  9. position:absolute;
  10. margin: 50px 200px;
  11. width:280px;
  12. height:200px;
  13. overflow:hidden;
  14. border-radius:6px;
  15. background-color: #000;
  16. }
  17. .imgdiv img{
  18. float:left;
  19. width:280px;
  20. height:200px;
  21. }
  22. .imgdiv {
  23. position: absolute;
  24. width: 1500px;
  25. }
  26. .play{
  27. animation: lbt 10s ;
  28. animation-direction: normal;
  29. animation-iteration-count: infinite;
  30. }
  31. .play:hover{
  32. animation-play-state: paused;
  33. }
  34. @keyframes lbt {
  35. 0%,20% {
  36. margin-left: 0px;
  37. }
  38. 20%,40% {
  39. margin-left: -300px;
  40. }
  41. 40%,60% {
  42. margin-left: -600px;
  43. }
  44. 60%,80% {
  45. margin-left: -900px;
  46. }
  47. 80%,100% {
  48. margin-left: -1200px;
  49. }
  50. }
  51. </style>
  52. </head>
  53. <body>
  54. <div class="frame" >
  55. <div class="imgdiv play">
  56. <img src="lunbo.jpg" > <!-- 引入照片 -->
  57. <img src="lunbo.jpg" >
  58. <img src="lunbo.jpg" >
  59. <img src="lunbo.jpg" >
  60. <img src="lunbo.jpg" >
  61. </div>
  62. </div>
  63. </body>
  64. </html>

1

蓝蓝设计建立了UI设计分享群,每天会分享国内外的一些优秀设计,如果有兴趣的话,可以进入一起成长学习,请扫码蓝小助,报下信息,蓝小助会请您入群。欢迎您加入噢~~希望得到建议咨询、商务合作,也请与我们联系。

截屏2021-05-13 上午11.41.03.png


部分借鉴自:csdn  

原文链接:

分享此文一切功德,皆悉回向给文章原作者及众读者.
免责声明:蓝蓝设计尊重原作者,文章的版权归原作者。如涉及版权问题,请及时与我们取得联系,我们立即更正或删除。

蓝蓝设计www.lanlanwork.com )是一家专注而深入的界面设计公司,为期望卓越的国内外企业提供卓越的UI界面设计、BS界面设计 、 cs界面设计 、 ipad界面设计 、 包装设计 、 图标定制 、 用户体验 、交互设计、 网站建设 平面设计服务

日历

链接

个人资料

蓝蓝设计的小编 http://www.lanlanwork.com

存档