css3繪製燃燒的蠟燭效果
分享一段程式碼例項,它實現了燃燒的蠟燭效果。
效果比較逼真,有搖曳的燭火的,還有下落的臘滴。
程式碼例項如下:
[HTML] 純文字檢視 複製程式碼執行程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style type="text/css"> body { width: 100%; height: 100vh; display: flex; justify-content: center; align-items: center; background: #402D35; } .container { width: 160px; height: 163px; position: relative; } .candle { width: 80px; height: 140px; background: #A65A51; border-radius: 8px; position: relative; margin: auto; z-index: 3; } .candle .top { width: 80px; height: 18px; background: #b97871; border-radius: 100%; position: absolute; top: -4px; overflow: hidden; } .candle .top .top_inner { width: 80px; height: 16px; background: #c28882; border-radius: 100%; position: absolute; top: 4px; } .candle .bottom { width: 80px; height: 18px; background: #A65A51; border-radius: 100%; position: absolute; bottom: -4px; } .candle .wax-drip { width: 9px; height: 12px; background: #c7928c; position: absolute; top: 10px; left: 8px; border-radius: 80% 0 55% 50%/55% 0 80% 50%; -webkit-transform: rotateZ(0); transform: rotateZ(0); } .candle .wax-drip .falling-wax { width: 6px; height: 6px; position: absolute; background: #c7928c; top: 8px; left: 1px; border-radius: 80% 0 55% 50%/55% 0 80% 50%; animation: waxDrop 5s linear infinite; } .wick { width: 4px; height: 15px; background: #111; position: absolute; z-index: 5; left: 50%; top: -8px; margin-left: -2px; } .flame { width: 18px; height: 18px; background: #FFD678; position: absolute; z-index: 6; border-radius: 80% 0 55% 50%/55% 0 80% 50%; left: 50%; top: -20px; margin-left: -9px; transform: rotateZ(-45deg); animation: flameFlicker 0.9s ease infinite; } .flame .inner-flame { width: 10px; height: 10px; background: #D1835C; position: absolute; z-index: 8; border-radius: 80% 0 55% 50%/55% 0 80% 50%; left: 50%; margin-left: -7px; bottom: 2px; opacity: 0.4; } .outer-glow { width: 200px; height: 200px; background: #6E4247; position: absolute; border-radius: 100%; left: -20px; top: -120px; opacity: 0.2; animation: glowFlicker 3s linear infinite; transform-origin: center center; } .outer-glow .inner-outer-glow { width: 70px; height: 70px; background: #8e555c; position: absolute; border-radius: 100%; opacity: 1; left: 50%; margin-left: -35px; top: 60px; } .plate { width: 160px; height: 40px; background: #444; border-radius: 100%; position: absolute; bottom: 5px; z-index: 2; } .plate .plate-inner { width: 90px; height: 30px; background: #4e4e4e; border-radius: 100%; position: absolute; left: 50%; margin-left: -45px; bottom: 9px; z-index: 2; } .plate-bottom { width: 100px; height: 40px; background: #373737; border-radius: 50%; position: absolute; bottom: 2px; z-index: 1; left: 50%; margin-left: -50px; } @keyframes flameFlicker { 0%, 100% { width: 16px; height: 17px; } 25% { width: 19px; height: 17px; } 50% { width: 17px; height: 16px; } 75% { width: 17px; height: 19px; } } @keyframes glowFlicker { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.4; -webkit-transform: scale(1.02); transform: scale(1.02); } } @keyframes waxDrop { from { -webkit-transform: translateY(0); transform: translateY(0); } to { -webkit-transform: translateY(120px); transform: translateY(120px); } } </style> </head> <body> <div class="container"> <div class="flame"> <div class="inner-flame"></div> </div> <div class="outer-glow"> <div class="inner-outer-glow"></div> </div> <div class="wick"></div> <div class="candle"> <div class="top"> <div class="top_inner"></div> </div> <div class="bottom"></div> <div class="wax-drip"> <div class="falling-wax"></div> </div> </div> <div class="plate"> <div class="lightning"></div> <div class="plate-inner"></div> </div> <div class="plate-bottom"></div> </div> </body> </html>
相關文章
- LuDela智慧蠟燭:可用手機遠端點燃熄滅
- 技術分析--日本蠟燭圖
- c++求生日蠟燭題目C++
- 使用CSS製作火焰燃燒動畫CSS動畫
- CSS3繪製圖形圖案效果CSSS3
- css3繪製月牙效果程式碼例項CSSS3
- canvas繪製流星效果Canvas
- bitcoin: 何為燃燒地址
- canvas繪製風車效果Canvas
- css3 繪製畫圓、扇形CSSS3
- CSS3繪製騰訊QQ企鵝CSSS3
- 燃燒吧!我的併發之魂–synchronizedsynchronized
- 燃燒吧!我的併發之魂--synchronizedsynchronized
- 用CSS3繪製iPhone手機CSSS3iPhone
- 使用 HTML5 Canvas 繪製的水滴效果HTMLCanvas
- canvas繪製卡通人臉形象效果Canvas
- canvas繪製多個圓圈效果Canvas
- canvas繪製網格射線效果Canvas
- 敏捷開發與jira之燃燒圖敏捷
- CSS3滾動視差效果的製作技巧CSSS3
- css3繪製跳動的紅心詳解CSSS3
- CSS3繪製菱形程式碼例項CSSS3
- 2016年藍橋杯C/C++組省賽第二題--生日蠟燭C++
- canvas繪製帶有漸變效果的直線Canvas
- 繪製聲音訊率的波紋動畫效果音訊動畫
- Flutter繪製-08-龍捲風效果Flutter
- canvas繪製經典星空連線效果Canvas
- canvas繪製太陽系運動效果Canvas
- canvas繪製北斗七星效果Canvas
- canvas繪製圓環效果程式碼例項Canvas
- css3繪製百度度熊CSSS3
- jQuery和CSS3繪製動態笑臉jQueryCSSS3
- CSS3繪製安卓系統機器人CSSS3安卓機器人
- 生存RTS《異星前哨》技術分享——燃燒你的CPU
- 使用 CSS 繪製帶有動畫效果的 React LogoCSS動畫ReactGo
- canvas繪製旋轉一定角度的矩形效果Canvas
- 使用html5實現的繪製直線效果HTML
- canvas繪製圓盤走動鐘錶效果Canvas