css簡(jiǎn)單樣式(旋轉(zhuǎn)正方形、紙片旋轉(zhuǎn)、輪播圖3D、簡(jiǎn)單輪播圖)

2021-6-10    前端達(dá)人

 
  1. 旋轉(zhuǎn)正方形
  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>旋轉(zhuǎn)立方體</title>
  8. <style type="text/css">
  9. .stage{
  10. position: relative;
  11. perspective: 800px;
  12. }
  13. @keyframes rotate-frame{ /* 設(shè)置動(dòng)畫效果 */
  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. /*覆蓋時(shí)暫停動(dòng)畫*/
  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); /* 設(shè)置角度 */
  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. /*讓倒置的數(shù)字倒置回正常狀態(tài)*/
  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. 紙片旋轉(zhuǎn)
  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. /*設(shè)置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 指定子元素定位在三維空間內(nèi) */
  18. transform-style: preserve-3d;
  19. /*指定變換為:linear-線性過(guò)渡*/
  20. transition-timing-function:linear;
  21. /*指定旋轉(zhuǎn)動(dòng)畫*/
  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. /*覆蓋時(shí)暫停動(dòng)畫*/
  32. animation-play-state: paused;
  33. }
  34. .b1{
  35. /*聲明第一個(gè)卡片為浮動(dòng),使得兩個(gè)卡片能重疊*/
  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. /*第二個(gè)卡片旋轉(zhuǎn)90度*/
  54. transform: rotateX(90deg);
  55. /*第二個(gè)卡片位于中間位置*/
  56. position: absolute;
  57. margin-left: 0;
  58. margin-top: 0;
  59. }
  60. .rotateX180{
  61. /*讓倒置的2、4數(shù)字倒置回正常狀態(tài)*/
  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; /*設(shè)置為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); /* 設(shè)置角度 */
  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; /* 當(dāng)鼠標(biāo)懸停的時(shí)候停止 */
  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

藍(lán)藍(lán)設(shè)計(jì)建立了UI設(shè)計(jì)分享群,每天會(huì)分享國(guó)內(nèi)外的一些優(yōu)秀設(shè)計(jì),如果有興趣的話,可以進(jìn)入一起成長(zhǎng)學(xué)習(xí),請(qǐng)掃碼藍(lán)小助,報(bào)下信息,藍(lán)小助會(huì)請(qǐng)您入群。歡迎您加入噢~~希望得到建議咨詢、商務(wù)合作,也請(qǐng)與我們聯(lián)系。

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


部分借鑒自:csdn  

原文鏈接:

分享此文一切功德,皆悉回向給文章原作者及眾讀者.
免責(zé)聲明:藍(lán)藍(lán)設(shè)計(jì)尊重原作者,文章的版權(quán)歸原作者。如涉及版權(quán)問(wèn)題,請(qǐng)及時(shí)與我們?nèi)〉寐?lián)系,我們立即更正或刪除。

藍(lán)藍(lán)設(shè)計(jì)m.yvirxh.cn )是一家專注而深入的界面設(shè)計(jì)公司,為期望卓越的國(guó)內(nèi)外企業(yè)提供卓越的UI界面設(shè)計(jì)、BS界面設(shè)計(jì) 、 cs界面設(shè)計(jì) 、 ipad界面設(shè)計(jì) 、 包裝設(shè)計(jì) 、 圖標(biāo)定制 、 用戶體驗(yàn) 、交互設(shè)計(jì)、 網(wǎng)站建設(shè) 、平面設(shè)計(jì)服務(wù)

日歷

鏈接

個(gè)人資料

存檔