jQuery中 响应翻转倒计时 响应翻转器

  • 源码大小:23.46KB
  • 所需积分:1积分
  • 源码编号:19JP-3784
  • 浏览次数:1076次
  • 最后更新:2023年07月22日
  • 所属栏目:时间和时钟
本站默认解压密码:19jp.com 或 19jp_com

简介

一个完全响应的jQuery和CSS3驱动的翻转时钟插件,以自定义日期时间格式显示数字倒计时计时器。

参见:

  • JavaScript中的7个最佳翻转时钟式倒计时插件

如何使用它:

1.为翻转倒计时时钟构建HTML。

  • 数据日期时间:日期时间
  • 数据模板:自定义格式
  • 数据标签:自定义标签
  • 数据反向:true=倒计时模式
  1. <div class="flipper"
  2. data-datetime="2020-01-01 00:00:00"
  3. data-template="ddd|HH|ii|ss"
  4. data-labels="Days|Hours|Minutes|Seconds"
  5. data-reverse="true"
  6. id="myFlipper">
  7. </div>

2.包含JavaScript文件jquery.flipper-aresponsive.js查询加载jQuery库之后。

  1. <script src="/path/to/jquery.slim.min.js"></script>
  2. <script src="/path/to/jquery.flipper-responsive.js"></script>

3.初始化翻转倒计时时钟。

  1. $(function(){
  2. $('#myFlipper').flipper('init');
  3. });

4.所需的CSS/CS3样式。

  1. .flipper {
  2. color: #333;
  3. display: block;
  4. font-size: 50px;
  5. line-height: 100%;
  6. padding: 0;
  7. margin: 0;
  8. height: 1.7em;
  9. }
  10. .flipper.flipper-invisible {
  11. font-size: 0px !important;
  12. }
  13.  
  14. .flipper-group {
  15. position: relative;
  16. white-space: nowrap;
  17. display: block;
  18. float: left;
  19. padding: 0;
  20. margin: 0;
  21. }
  22. .flipper-group label {
  23. position: absolute;
  24. color: #fff;
  25. font-size: 20%;
  26. top: 100%;
  27. line-height: 1em;
  28. left: 50%;
  29. -webkit-transform: translate(-50%, 0);
  30. transform: translate(-50%, 0);
  31. text-align: center;
  32. padding-top: .5em;
  33. }
  34.  
  35. .flipper-digit {
  36. white-space: nowrap;
  37. position: relative;
  38. padding: 0;
  39. margin: 0;
  40. display: inline-block;
  41. float: left;
  42. height: 1.2em;
  43. overflow-y: hidden;
  44. }
  45. .flipper-digit span {
  46. font-size: 25%;
  47. }
  48.  
  49. .flipper-delimiter {
  50. white-space: nowrap;
  51. display: block;
  52. float: left;
  53. padding: 0;
  54. margin: 0;
  55. color: #fff;
  56. min-width: .1em;
  57. white-space: nowrap;
  58. display: block;
  59. padding-top: 0.1em;
  60. padding-bottom: 0.1em;
  61. line-height: 1em;
  62. }
  63.  
  64. .digit-face {
  65. display: block;
  66. visibility: hidden;
  67. position: relative;
  68. border-radius: 0.1em;
  69. top: 0;
  70. left: 0;
  71. right: 0;
  72. bottom: 0;
  73. z-index: 8;
  74. padding-top: 0.1em;
  75. padding-bottom: 0.1em;
  76. padding-left: 0.1em;
  77. padding-right: 0.1em;
  78. box-sizing: border-box;
  79. text-align: center;
  80. }
  81.  
  82. .digit-next {
  83. display: block;
  84. position: relative;
  85. border-radius: 0.1em;
  86. top: 0;
  87. left: 0;
  88. right: 0;
  89. bottom: 0;
  90. z-index: 8;
  91. height: 1.2em;
  92. background: #fff;
  93. padding-top: 0.1em;
  94. padding-bottom: 0.1em;
  95. padding-left: 0.1em;
  96. padding-right: 0.1em;
  97. box-sizing: border-box;
  98. text-align: center;
  99. -webkit-user-select: none;
  100. -moz-user-select: none;
  101. -ms-user-select: none;
  102. user-select: none;
  103. }
  104.  
  105. .digit-top {
  106. z-index: 10;
  107. top: 0;
  108. left: 0;
  109. right: 0;
  110. height: 50%;
  111. -webkit-backface-visibility: hidden;
  112. backface-visibility: hidden;
  113. pointer-events: none;
  114. overflow: hidden;
  115. position: absolute;
  116. background: #fff;
  117. padding-top: 0.1em;
  118. padding-bottom: 0;
  119. padding-left: 0.1em;
  120. padding-right: 0.1em;
  121. border-top-left-radius: 0.1em;
  122. border-top-right-radius: 0.1em;
  123. box-sizing: border-box;
  124. text-align: center;
  125. -webkit-user-select: none;
  126. -moz-user-select: none;
  127. -ms-user-select: none;
  128. user-select: none;
  129. transition: background 0s linear, -webkit-transform 0s linear;
  130. transition: transform 0s linear, background 0s linear;
  131. transition: transform 0s linear, background 0s linear, -webkit-transform 0s linear;
  132. -webkit-transform-origin: 0 0.6em 0 !important;
  133. transform-origin: 0 0.6em 0 !important;
  134. -webkit-transform-style: preserve-3d !important;
  135. transform-style: preserve-3d !important;
  136. z-index: 20;
  137. }
  138. .digit-top.r {
  139. transition: background 0.2s linear, -webkit-transform 0.2s linear;
  140. transition: transform 0.2s linear, background 0.2s linear;
  141. transition: transform 0.2s linear, background 0.2s linear, -webkit-transform 0.2s linear;
  142. -webkit-transform: rotateX(90deg);
  143. transform: rotateX(90deg);
  144. background: #cccccc;
  145. }
  146.  
  147. .digit-top2 {
  148. visibility: hidden;
  149. position: absolute;
  150. height: 50%;
  151. left: 0;
  152. right: 0;
  153. background: #cccccc;
  154. transition: -webkit-transform 0.2s linear;
  155. transition: transform 0.2s linear;
  156. transition: transform 0.2s linear, -webkit-transform 0.2s linear;
  157. line-height: 0em !important;
  158. top: 50% !important;
  159. bottom: auto !important;
  160. padding-top: 0;
  161. padding-bottom: 0.1em;
  162. padding-left: 0.1em;
  163. padding-right: 0.1em;
  164. border-bottom-left-radius: 0.1em;
  165. border-bottom-right-radius: 0.1em;
  166. overflow: hidden;
  167. text-align: center;
  168. -webkit-user-select: none;
  169. -moz-user-select: none;
  170. -ms-user-select: none;
  171. user-select: none;
  172. transition: background 0s linear, -webkit-transform 0s linear;
  173. transition: transform 0s linear, background 0s linear;
  174. transition: transform 0s linear, background 0s linear, -webkit-transform 0s linear;
  175. -webkit-transform: rotateX(-90deg);
  176. transform: rotateX(-90deg);
  177. -webkit-transform-style: preserve-3d !important;
  178. transform-style: preserve-3d !important;
  179. -webkit-transform-origin: 0 0 0 !important;
  180. transform-origin: 0 0 0 !important;
  181. z-index: 20;
  182. }
  183. .digit-top2.r {
  184. visibility: visible;
  185. transition: background 0.2s linear 0.2s, -webkit-transform 0.2s linear 0.2s;
  186. transition: transform 0.2s linear 0.2s, background 0.2s linear 0.2s;
  187. transition: transform 0.2s linear 0.2s, background 0.2s linear 0.2s, -webkit-transform 0.2s linear 0.2s;
  188. -webkit-transform: rotateX(0deg);
  189. transform: rotateX(0deg);
  190. background: #fff;
  191. }
  192.  
  193. .digit-bottom {
  194. -webkit-backface-visibility: hidden;
  195. backface-visibility: hidden;
  196. pointer-events: none;
  197. position: absolute;
  198. overflow: hidden;
  199. background: #fff;
  200. height: 50%;
  201. left: 0;
  202. right: 0;
  203. bottom: 0;
  204. z-index: 9;
  205. line-height: 0em;
  206. padding-top: 0;
  207. padding-bottom: 0.1em;
  208. padding-left: 0.1em;
  209. padding-right: 0.1em;
  210. border-bottom-left-radius: 0.1em;
  211. border-bottom-right-radius: 0.1em;
  212. box-sizing: border-box;
  213. text-align: center;
  214. transition: none;
  215. }
  216. .digit-bottom.r {
  217. transition: background 0.2s linear;
  218. background: #cccccc;
  219. }
  220.  
  221. .flipper-digit:after {
  222. content: "";
  223. position: absolute;
  224. height: 2px;
  225. background: rgba(0, 0, 0, 0.5);
  226. top: 50%;
  227. display: block;
  228. z-index: 30;
  229. left: 0;
  230. right: 0;
  231. }

更新日志:

2021-12-08

  • 更新jquery.flipper-aresponsive.js

预览截图