jquery和css實現的圓形鐘錶效果
分享一段程式碼例項,它實現了圓形鐘錶效果。
程式碼例項如下:
[HTML] 純文字檢視 複製程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style> * { padding: 0; margin: 0; border: none; } body, html { width: 100%; height: 100%; } .box { width: 100%; height: 100%; position: relative; } .box_top, .box_bottom { width: 100%; height: 50%; position: absolute; z-index: 0; left: 0; top: 0; } .box_bottom { background: #3598db; position: absolute; z-index: 0; left: 0; top: 50%; } .clock { width: 500px; height: 500px; position: relative; left: 50%; top: 50%; margin: -250px 0 0 -250px; background: #3598db; border-radius: 50%; } .nmb { position: relative; width: 100%; height: 100%; } .nmb div { position: absolute; width: 220px; height: 24px; left: 30px; top: 50%; margin: -12px 0 0 0; display: block; font-weight: bold; font-size: 24px; transform: rotate(0deg); transform-origin: right center; } .nmb div span { position: absolute; color: #fff; } .sec, .min, .hou { position: absolute; left: 50%; transform-origin: center bottom; z-index: 10; } .sec { background: #d22; height: 200px; width: 2px; margin: 0 0 0 -1px; top: 50px; z-index: 100; } .min { height: 170px; width: 6px; margin: 0 0 0 -3px; top: 80px; background: #fff; border-radius: 4px; } .hou { height: 140px; width: 10px; margin: 0 0 0 -5px; top: 110px; background: #fff; border-radius: 5px; } .keduxian div { width: 248px; position: absolute; left: 2px; top: 50%; margin: -1px 0 0 0; transform-origin: right center; } .keduxian p { background: #fff; width: 8px; height: 2px; border-radius: 0 2px 2px 0; } .yuanxin { width: 10px; height: 10px; background: #d22; border-radius: 5px; top: 50%; left: 50%; margin: -5px 0 0 -5px; position: absolute; z-index: 999; } </style> </head> <body> <div class="box"> <div class="clock"> <div class="nmb"> <div><span>9</span></div> <div><span>10</span></div> <div><span>11</span></div> <div><span>12</span></div> <div><span>1</span></div> <div><span>2</span></div> <div><span>3</span></div> <div><span>4</span></div> <div><span>5</span></div> <div><span>6</span></div> <div><span>7</span></div> <div><span>8</span></div> </div> <div class="keduxian"></div> <div class="sec"></div> <div class="min"></div> <div class="hou"></div> <div class="yuanxin"></div> </div> </div> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> <script> $(function() { for (var i = 0; i < 12; i++) { $('.nmb div').eq(i).css('transform', 'rotate(' + i * 30 + 'deg)'); $('.nmb div').eq(i).find('span').css('transform', 'rotate(' + i * -30 + 'deg)'); } for (var j = 0; j < 60; j++) { var keduxian = $('<div><p></p></div>'); $('.keduxian').append(keduxian); $('.keduxian div').eq(j).css('transform', 'rotate(' + j * 6 + 'deg)'); if (j % 5 == 0) { $('.keduxian div').eq(j).find('p').css('width', '20px').css('height', '4px'); } } setInterval('aa()', 1000); }) function aa() { var time = new Date(); var sec = time.getSeconds(); var min = time.getMinutes() + time.getSeconds() / 60; var hou = time.getHours() + time.getMinutes() / 60; $('.sec').css('transform', 'rotate(' + sec * 6 + 'deg)'); $('.min').css('transform', 'rotate(' + min * 6 + 'deg)'); $('.hou').css('transform', 'rotate(' + hou * 30 + 'deg)'); } </script> </body> </html>
相關文章
- js和css3實現的圓形鐘錶效果JSCSSS3
- css3和js實現的圓形鐘錶效果程式碼例項CSSS3JS
- canvas實現的圓形走動鐘錶效果Canvas
- SVG圓形鐘錶效果SVG
- JavaScript圓形鐘錶效果JavaScript
- css3動態圓形鐘錶效果CSSS3
- canvas實現的圓形鐘錶效果程式碼例項Canvas
- canvas實現的圓形時鐘效果Canvas
- jquery自動走動的圓形鐘錶效果程式碼例項jQuery
- JavaScript動態圓形鐘錶效果詳解JavaScript
- css實現圓形、橢圓和半圓效果程式碼例項CSS
- jQuery和css3實現的電子錶效果jQueryCSSS3
- javascript圓形電子鐘錶效果程式碼例項JavaScript
- CSS3圓形時鐘效果程式碼CSSS3
- jquery和css3實現的動態時鐘效果jQueryCSSS3
- JavaScript 動態圓形鐘錶JavaScript
- PyQt實現鐘錶效果QT
- canvas圓形時鐘效果Canvas
- 【譯】使用CSS Transitions實現圓形懸停效果CSS
- CSS圓形圖片效果CSS
- javascript圓形鐘錶程式碼例項JavaScript
- css3和javascript實現的時鐘效果CSSS3JavaScript
- canvas繪製圓盤走動鐘錶效果Canvas
- css實現圓角按鈕效果CSS
- canvas繪製圓形鐘錶程式碼例項Canvas
- 13 - CSS3 - 邊框圓角 - 鐘錶CSSS3
- CSS3圓形進度條效果CSSS3
- css3實現的矩形圓角切角效果CSSS3
- jQuery和css3實現的摩天輪旋轉效果jQueryCSSS3
- css3和jQuery實現的點選出現波紋效果CSSS3jQuery
- jquery和css3實現的巴西里約奧運火炬效果jQueryCSSS3
- CSS3實現的圓球放大縮小效果CSSS3
- 圓形放大的hover效果
- CSS3標懸浮圓形縮放效果CSSS3
- CSS3圓形旋轉變大動畫效果CSSS3動畫
- 分享 用CSS實現無圖片圓角效果CSS
- CSS實現三角形效果CSS
- jQuery和css3實現的開關效果程式碼例項jQueryCSSS3