圓形小球環形均勻分佈程式碼例項
分享一段程式碼例項,它實現了小球環形圍繞的效果。
並且小球是均勻分佈的,程式碼例項如下:
[HTML] 純文字檢視 複製程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style type="text/css"> .centerDiv { width: 600px; height: 600px; margin: 0 auto; margin-top: 200px; position: relative; } .dashedCircle { height: 300px; width: 300px; border-radius: 100%; border: 1px dashed #494949; margin: 0 auto; } .circle, .circleCenter { width: 40px; height: 40px; line-height: 40px; text-align: center; color: #fff; background: #97e49a; border-radius: 100%; position: absolute; } .circleCenter { width: 20px; height: 20px; line-height: 20px; } </style> <script type="text/javascript"> window.onload = function () { var dx = 280, dy = 130, s = 180,//半徑 x = Math.sin(0), y = Math.cos(0), dig = 2 * Math.PI / 12; var circle = document.querySelectorAll(".circle"); for (var index = 0; index < 12; index++) { var x = Math.sin(index * dig); var y = Math.cos(index * dig); var topValue = Number(dy + y * s), leftValue = Number(dx + x * s); circle[index].style.top = topValue + "px"; circle[index].style.left = leftValue + "px"; } var circleCenterObj = document.querySelector(".circleCenter"); circleCenterObj.style.top = Number(dy) + 10;//10是中心小圓半徑 circleCenterObj.style.left = Number(dx) + 10; } </script> </head> <body> <div class="centerDiv"> <div class="dashedCircle"></div> <div class="circleCenter"></div> <div class="circle">7</div> <div class="circle">6</div> <div class="circle">5</div> <div class="circle">4</div> <div class="circle">3</div> <div class="circle">2</div> <div class="circle">1</div> <div class="circle">12</div> <div class="circle">11</div> <div class="circle">10</div> <div class="circle">9</div> <div class="circle">8</div> </div> </body> </html>
相關文章
- flex產品列表均勻分佈程式碼例項Flex
- js圓形環繞運動程式碼例項JS
- javascript圓形鐘錶程式碼例項JavaScript
- css繪製圓形程式碼例項CSS
- css3橢圓形程式碼例項CSSS3
- html5利用canvas圓形和多邊形程式碼例項HTMLCanvas
- canvas繪製圓形鐘錶程式碼例項Canvas
- canvas繪製實心圓形程式碼例項Canvas
- css實現圓形、橢圓和半圓效果程式碼例項CSS
- javascript圓形電子鐘錶效果程式碼例項JavaScript
- canvas實現的圓形鐘錶效果程式碼例項Canvas
- CSS等寬均勻分佈效果CSS
- border-radius繪製圓形圖案程式碼例項
- 2D圓形隨機分佈隨機
- css水平元素寬度自適應均勻排列程式碼例項CSS
- css 心形效果程式碼例項CSS
- jquery自動走動的圓形鐘錶效果程式碼例項jQuery
- css六邊形效果程式碼例項CSS
- css3和js實現的圓形鐘錶效果程式碼例項CSSS3JS
- javascript輸出菱形圖形程式碼例項JavaScript
- CSS3心形效果程式碼例項CSSS3
- jquery小球碰撞效果程式碼例項jQuery
- CSS3梯形效果程式碼例項CSSS3
- javascript樹形導航選單例項程式碼JavaScript單例
- css樹形導航選單程式碼例項CSS
- javascript繪製心形圖案程式碼例項JavaScript
- canvas實現的多邊形程式碼例項Canvas
- NumPy 均勻分佈模擬及 Seaborn 視覺化教程視覺化
- javascript元素勻速運動程式碼例項JavaScript
- CSS自定義滑鼠指標形狀程式碼例項CSS指標
- 自定義圓形View:實現跟隨手指移動的小球View
- js小球拋物線效果程式碼例項JS
- canvas小球隨機漂浮碰撞程式碼例項Canvas隨機
- CSS3圓形時鐘效果程式碼CSSS3
- javascript圓形區域碰撞檢測程式碼JavaScript
- css3實現平行四邊形程式碼例項CSSS3
- js獲取指定函式的形參程式碼例項JS函式
- css三角形箭頭程式碼例項CSS