日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

css3 翻转

發(fā)布時間:2023/12/14 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 css3 翻转 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

參考資料:

  WEB駭客 ?: ?http://www.webhek.com/css-flip/

?

Demo :?Demo?(谷歌瀏覽器觀看,沒做兼容)

Demo截圖:

代碼:

1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 <style> 7 *{ margin:0;padding:0; font-family: '微軟雅黑','宋體'; } 8 9 @-webkit-keyframes circling{ 10 0% { 11 -webkit-transform:rotate(-90deg); 12 } 13 100% { 14 -webkit-transform:rotate(270deg); 15 } 16 } 17 18 @-webkit-keyframes circling2{ 19 0% { 20 -webkit-transform:rotate(-90deg); 21 } 22 100% { 23 -webkit-transform:rotate(-450deg); 24 } 25 } 26 @-webkit-keyframes fast-circling{ 27 0% { 28 -webkit-transform:rotate(-90deg); 29 } 30 100% { 31 -webkit-transform:rotate(270deg); 32 } 33 } 34 35 @-webkit-keyframes fast-circling2{ 36 0% { 37 -webkit-transform:rotate(-90deg); 38 } 39 100% { 40 -webkit-transform:rotate(-450deg); 41 } 42 } 43 44 .center{ width:950px; margin:100px auto; } 45 .cir-main{ position: relative;width:1px;height:1px; margin:300px auto;-webkit-perspective: 1000;} 46 .circling-1,.circling-2{position: absolute;border-radius: 50%;border:2px solid #e4e4e4; } 47 .circling-1{ left:-250px;top:-250px;width:500px;height:500px; } 48 .circling-2{left:-225px;top:-225px; width:450px;height:450px; } 49 .line-1,.line-2{position: absolute;left:0;top:0;height:1px;transform-origin:left center; 50 -webkit-transform:rotate(-90deg); 51 -webkit-animation-iteration-count: infinite; 52 -webkit-animation-direction: normal; 53 -webkit-animation-duration: 10s; 54 -webkit-animation-timing-function: linear; 55 } 56 57 .line-1{ 58 59 width:250px; 60 -webkit-animation-name: circling; 61 62 } 63 64 .line-1:after,.line-2:after{ content:""; position: absolute;right:-12px;top:0; margin:-9px 0 0 0; display: block; width:20px;height:20px; background-color: #7acfe7; border-radius: 50%;opacity: 0.8; } 65 .line-2{ 66 67 width:225px; 68 -webkit-animation-name: circling2; 69 70 } 71 72 .cir-main.cur .line-1,.cir-main.cur .line-2{ 73 74 -webkit-animation-duration: 1.5s; 75 -webkit-animation-timing-function: cubic-bezier(0,.62,.24,.88); 76 77 } 78 .cir-main.cur .line-1{ 79 80 -webkit-animation-name: fast-circling; 81 82 } 83 .cir-main.cur .line-2{ 84 85 -webkit-animation-name: fast-circling2; 86 87 } 88 .cir-main .paused{ 89 -webkit-animation-play-state:paused; 90 } 91 .turn{ position: absolute;left:-150px;top:-150px; width:300px;height:300px; cursor: pointer;transform-style: preserve-3d; transition: 0.6s;} 92 .on,.off{position: absolute; width:300px;height:300px;border-radius: 50%;border:1px solid #e4e4e4; text-align:center; line-height: 300px; font-size: 30px; transform-origin:center center;transition: 0.6s;transform-style: preserve-3d;backface-visibility: hidden;} 93 .on{ background-color: rgba(232,243,247,1);color: #333; z-index: 2; -webkit-transform: rotateY(0deg);} 94 .off{ background-color: rgba(244,163,176,1);color: #fff;transform: rotateY(-180deg); } 95 .turn.cur .on{ transform: rotateY(180deg); } 96 .turn.cur .off{ transform: rotateY(0deg); } 97 98 </style> 99 <script> 100 window.onload = function(){ 101 102 var oMain = document.querySelector('.cir-main'); 103 var oTurn = document.querySelector('.turn'); 104 var oline1 = document.querySelector('.line-1'); 105 var oline2 = document.querySelector('.line-2'); 106 107 var timer = null; 108 var btn = false; 109 110 oTurn.onclick = function(){ 111 112 clearTimeout( timer ); 113 114 if( btn ){ 115 116 117 this.className = 'turn'; 118 119 oMain.className = 'cir-main'; 120 121 }else{ 122 123 clearTimeout( timer ); 124 125 this.className = 'turn cur'; 126 127 } 128 129 oMain.className = 'cir-main cur'; 130 131 timer = setTimeout(function(){ 132 133 oMain.className = 'cir-main'; 134 135 clearTimeout( timer ); 136 137 },1500); 138 139 btn = !btn; 140 141 } 142 143 } 144 </script> 145 </head> 146 <body> 147 <div class="center"> 148 149 <div class="cir-main"> 150 <div class="circling-1" ></div> 151 <div class="circling-2"></div> 152 <div class="line-1"></div> 153 <div class="line-2"></div> 154 <div class="turn"> 155 <div class="on"> 156 點擊開啟 157 </div> 158 <div class="off"> 159 點擊關(guān)閉 160 </div> 161 </div> 162 </div> 163 </div> 164 </body> 165 </html> View Code

?

后記:

1.上下翻轉(zhuǎn)是 X軸翻轉(zhuǎn)(rotateX),左右翻轉(zhuǎn)是Y軸翻轉(zhuǎn)(rotateY);

2.backface-visibility: hidden;背面的隱藏;

3.圓點其實沒有動是長方形的div?rotate 做的;

4.重點:

  如果想動態(tài)更改?animation-duration 的完成速度時間 有兩個方法:

  一、給旋轉(zhuǎn)的對象換不同的class 更改?animation并且animation-name必須賦一個新的keyframes?否則不生效;

  二、JS 修改?animation-duration、animation-name 兩個值必須同時修改 并且?animation-name 必須賦一個新的keyframes否則不生效;;

?

轉(zhuǎn)載于:https://www.cnblogs.com/auok/p/4754613.html

總結(jié)

以上是生活随笔為你收集整理的css3 翻转的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。