css3漂浮氣球效果程式碼例項
本章節分享一段程式碼例項,它利用css3實現了漂浮的氣球的效果。
類似於一種宣傳或者節日慶祝的東西。
程式碼例項如下:
[HTML] 純文字檢視 複製程式碼執行程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style> span { text-transform: uppercase; } .container { width: 800px; height: 420px; padding: 0; position: relative; } .balloon { width: 738px; margin: 0 auto; padding-top: 30px; position: relative; } .balloon > div { width: 104px; height: 140px; background: rgba(182, 15, 97, 0.9); border-radius: 0; border-radius: 80% 80% 80% 80%; margin: 0 auto; position: absolute; padding: 10px; box-shadow: inset 17px 7px 10px rgba(182, 15, 97, 0.9); transform-origin: bottom center; } .balloon > div:nth-child(1) { background: rgba(182, 15, 97, 0.9); left: 0; box-shadow: inset 10px 10px 10px rgba(135, 11, 72, 0.9); animation: balloon1 6s ease-in-out infinite; } .balloon > div:nth-child(1):before { color: rgba(182, 15, 97, 0.9); } .balloon > div:nth-child(2) { background: rgba(242, 112, 45, 0.9); left: 120px; box-shadow: inset 10px 10px 10px rgba(222, 85, 14, 0.9); animation: balloon2 6s ease-in-out infinite; } .balloon > div:nth-child(2):before { color: rgba(242, 112, 45, 0.9); } .balloon > div:nth-child(3) { background: rgba(45, 181, 167, 0.9); left: 240px; box-shadow: inset 10px 10px 10px rgba(35, 140, 129, 0.9); animation: balloon4 6s ease-in-out infinite; } .balloon > div:nth-child(3):before { color: rgba(45, 181, 167, 0.9); } .balloon > div:nth-child(4) { background: rgba(190, 61, 244, 0.9); left: 360px; box-shadow: inset 10px 10px 10px rgba(173, 14, 240, 0.9); animation: balloon1 5s ease-in-out infinite; } .balloon > div:nth-child(4):before { color: rgba(190, 61, 244, 0.9); } .balloon > div:nth-child(5) { background: rgba(180, 224, 67, 0.9); left: 480px; box-shadow: inset 10px 10px 10px rgba(158, 206, 34, 0.9); animation: balloon3 5s ease-in-out infinite; } .balloon > div:nth-child(5):before { color: rgba(180, 224, 67, 0.9); } .balloon > div:nth-child(6) { background: rgba(242, 194, 58, 0.9); left: 600px; box-shadow: inset 10px 10px 10px rgba(234, 177, 15, 0.9); animation: balloon2 3s ease-in-out infinite; } .balloon > div:nth-child(6):before { color: rgba(242, 194, 58, 0.9); } .balloon > div:before { color: rgba(182, 15, 97, 0.9); position: absolute; bottom: -11px; left: 52px; content: "▲"; font-size: 1em; } span { font-size: 4.8em; color: white; position: relative; top: 14px; left: 41%; margin-left: -27px; } @keyframes balloon1 { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-20px) rotate(8deg); } } @keyframes balloon2 { 0%, 100% { transform: translateY(0) rotate(6deg); } 50% { transform: translateY(-30px) rotate(-8deg); } } @keyframes balloon3 { 0%, 100% { transform: translate(0, -10px) rotate(6deg); } 50% { transform: translate(-20px, 30px) rotate(-8deg); } } /* BAllOON 3*/ @keyframes balloon4 { 0%, 100% { transform: translate(10px, -10px) rotate(-8deg); } 50% { transform: translate(-15px, 10px) rotate(10deg); } } h1 { position: relative; top: 200px; text-align: center; color: white; font-size: 3.5em; } </style> </head> <body> <div class="container"> <div class="balloon"> <div><span>螞</span></div> <div><span>蟻</span></div> <div><span>部</span></div> <div><span>落</span></div> <div><span>歡</span></div> <div><span>迎</span></div> <div><span>您</span></div> </div> </div> </body> </html>
相關文章
- css3水滴效果程式碼例項CSSS3
- css3晃動效果程式碼例項CSSS3
- CSS3心形效果程式碼例項CSSS3
- CSS3旋轉效果程式碼例項CSSS3
- canvas氣泡上浮效果程式碼例項Canvas
- CSS3滑過光束效果程式碼例項CSSS3
- CSS3小黃人效果程式碼例項CSSS3
- css3折角效果程式碼例項CSSS3
- CSS3梯形效果程式碼例項CSSS3
- CSS3背景漸變效果程式碼例項CSSS3
- CSS3星系運動效果程式碼例項CSSS3
- CSS3文字凹凸效果程式碼例項CSSS3
- CSS3文字陰影效果程式碼例項CSSS3
- CSS3卡通形象程式碼例項CSSS3
- jQuery tab選項卡效果程式碼例項jQuery
- canvas載入效果程式碼例項Canvas
- CSS橢圓效果程式碼例項CSS
- CSS3發光背景程式碼例項CSSS3
- CSS3紙飛機程式碼例項CSSS3
- 美化滾動條效果程式碼例項
- canvas原型鐘錶效果程式碼例項Canvas原型
- css背景虛化效果程式碼例項CSS
- CSS3圖層陰影程式碼例項CSSS3
- jQuery點選滑出層效果程式碼例項jQuery
- div前後翻轉效果程式碼例項
- 當前文字框高亮效果程式碼例項
- 淡入淡出效果簡單程式碼例項
- canvas繪製箭頭效果程式碼例項Canvas
- CSS3箭靶效果程式碼CSSS3
- CSS3 loadding效果程式碼CSSS3
- CSS3立體導航選單程式碼例項CSSS3
- 商品搶購倒數計時效果程式碼例項
- html實現簡單ListViews效果的例項程式碼HTMLView
- CSS3 Flex 彈性佈局例項程式碼詳解CSSS3Flex
- CSS3繪製太極圖程式碼例項詳解CSSS3
- CSS3 translate導致字型模糊的例項程式碼CSSS3
- CSS3圓環效果程式碼CSSS3
- CSS3現菱形效果程式碼CSSS3
- CSS3紅色心形效果程式碼CSSS3