CSS3星系運動效果程式碼例項
分享一段程式碼例項,它實現了簡單的星系運動效果。
所謂的星系運動簡單的說就是一群行星圍繞一個恆星轉動。
程式碼例項如下:
[HTML] 純文字檢視 複製程式碼執行程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style> body { margin: 0; padding: 0; background-image: url(bg.jpg); } ul { width: 600px; height: 600px; margin: 40px auto; position: relative; list-style: none; } ul li { border-radius: 50%; position: absolute; border: 2px solid #394057; top: 50%; left: 50%; /*水平垂直居中*/ transform: translate(-50%, -50%); /*2 把定義好的動畫應用*/ animation-name: rotate; animation-timing-function: linear; animation-iteration-count: infinite; } ul li span { display: block; position: absolute; border-radius: 50%; } li:nth-child(1) { width: 60px; height: 60px; border: none; background-color: #c90; box-shadow: 0 0 50px #c90; animation-duration: 5s; } li:nth-child(2) { width: 120px; height: 120px; animation-duration: 10s; } li:nth-child(2) span { width: 12px; height: 12px; top: 25px; background-color: yellow; } li:nth-child(3) { width: 180px; height: 180px; animation-duration: 20s; } li:nth-child(3) span { width: 12px; height: 12px; top: 48px; background-color: blue; } li:nth-child(4) { width: 240px; height: 240px; animation-duration: 30s; } li:nth-child(4) > span { width: 12px; height: 12px; top: 72px; background-color: green; animation-name: rotate; animation-timing-function: linear; animation-iteration-count: infinite; animation-duration: 1s; } li:nth-child(4) > span span { width: 6px; height: 6px; position: absolute; top: 16px; background-color: yellow; } li:nth-child(5) { width: 300px; height: 300px; animation-duration: 2s; } li:nth-child(5) span { width: 16px; height: 16px; top: 90px; background-color: red; } li:nth-child(6) { width: 360px; height: 360px; } li:nth-child(7) { width: 420px; height: 420px; } li:nth-child(8) { width: 480px; height: 480px; } li:nth-child(9) { width: 540px; height: 540px; } li:nth-child(10) { width: 600px; height: 600px; } /*定義動畫*/ @keyframes rotate { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } } </style> </head> <body> <ul> <li></li> <li><span></span></li> <li><span></span></li> <li> <span><span></span></span> </li> <li><span></span></li> <li><span></span></li> <li> <span><span></span></span> </li> <li><span></span></li> <li><span></span></li> <li><span></span></li> </ul> </body> </html>
相關文章
- css3晃動效果程式碼例項CSSS3
- css3水滴效果程式碼例項CSSS3
- CSS3心形效果程式碼例項CSSS3
- CSS3旋轉效果程式碼例項CSSS3
- CSS3滑過光束效果程式碼例項CSSS3
- CSS3小黃人效果程式碼例項CSSS3
- css3折角效果程式碼例項CSSS3
- CSS3梯形效果程式碼例項CSSS3
- CSS3背景漸變效果程式碼例項CSSS3
- CSS3文字凹凸效果程式碼例項CSSS3
- CSS3文字陰影效果程式碼例項CSSS3
- 美化滾動條效果程式碼例項
- CSS3星系旋轉效果代CSSS3
- JavaScript運動框架程式碼例項JavaScript框架
- CSS3地月星系旋轉效果CSSS3
- CSS3卡通形象程式碼例項CSSS3
- jQuery tab選項卡效果程式碼例項jQuery
- canvas載入效果程式碼例項Canvas
- CSS橢圓效果程式碼例項CSS
- CSS3發光背景程式碼例項CSSS3
- CSS3紙飛機程式碼例項CSSS3
- JavaScript in運算子程式碼例項JavaScript
- CSS3滾動條效果程式碼CSSS3
- canvas原型鐘錶效果程式碼例項Canvas原型
- css背景虛化效果程式碼例項CSS
- canvas氣泡上浮效果程式碼例項Canvas
- CSS3圖層陰影程式碼例項CSSS3
- jQuery點選滑出層效果程式碼例項jQuery
- div前後翻轉效果程式碼例項
- 當前文字框高亮效果程式碼例項
- 淡入淡出效果簡單程式碼例項
- canvas繪製箭頭效果程式碼例項Canvas
- CSS3 div水平運動效果CSSS3
- CSS3立體導航選單程式碼例項CSSS3
- CSS3箭靶效果程式碼CSSS3
- CSS3 loadding效果程式碼CSSS3
- html實現簡單ListViews效果的例項程式碼HTMLView
- 商品搶購倒數計時效果程式碼例項