jQuery和CSS3繪製動態笑臉
分享一段程式碼例項,它利用jQuery和css3繪製了動態笑臉效果。
滑鼠懸浮於眼睛和嘴巴之上會有動態效果。
程式碼例項如下
[HTML] 純文字檢視 複製程式碼執行程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style> * { box-sizing: border-box; } .container { width: 400px; min-height: 400px; background-color: yellow; overflow: auto; display: block; margin: 0 auto; border-radius: 200px; } .eyebox { width: 400px; display: block; margin: 0 auto; text-align: center; margin-top: 100px; margin-bottom: 60px; } .eye { height: 100px; width: 100px; background-color: white; border: 4px solid white; border-radius: 100%; display: inline-block; margin: 0 20px; position: relative; padding: 20px; overflow: hidden; } .eye .pupil { height: 25px; width: 25px; border-radius: 100%; display: inline-block; background-color: black; position: absolute; margin-left: -10px; left: 50px; margin: 10px; } .smile { height: 100px; width: 200px; border-radius: 0 0 200px 200px; background: #ee3a4c; margin: 0 auto; overflow: hidden; transition: all .4s; transform-origin: center; } .smile:hover { transition: all .4s; height: 33.33333px; width: 33.33333px; border-radius: 100%; margin-top: 120px; } .smile:hover .teeth { margin-left: -25px; margin-top: -40px; transition: all .4s; } .smile:hover .tongue { transition: all .4s; margin-left: -50px; } .smile .teeth { background-color: #fff; transition: all .4s; height: 33.33333px; width: 33.33333px; margin-left: 56.66667px; position: relative; } .smile .teeth:after { content: ""; background-color: #fff; height: 33.33333px; width: 33.33333px; position: absolute; left: 50px; top: 0; z-index: 10000; } .smile .tongue { transition: all .4s; height: 100px; width: 100px; background-color: pink; border-radius: 100%; margin-top: 40px; margin-left: 15px; display: inline-block; position: relative; } .smile .tongue:after { content: ''; height: 100px; width: 100px; background-color: pink; border-radius: 100%; display: inline-block; position: absolute; left: 50px; } </style> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> <script> $(function() { var limitX = 50, limitY = 50; var containerW = $('.container').width(); var containerH = $('.container').height(); $(".container").mousemove(function(e) { var mouseY = Math.min(e.clientY / (containerH * .01), limitY); var mouseX = Math.min(e.clientX / (containerW * .01), limitX); $('.pupil').css('top', mouseY); $('.pupil').css('left', mouseX); console.log(e.clientY + ' ' + e.clientX); }); }); </script> </head> <body> <div class="container"> <div class="eyebox"> <div class="eye EL"> <div class="pupil"></div> </div> <div class="eye ER"> <div class="pupil"></div> </div> </div> <div class="smile"> <div class="teeth"></div> <div class="tongue"></div> </div> </div> <div class="readout"></div> </body> </html>
相關文章
- canvas繪製笑臉表情Canvas
- canvas繪製笑臉程式碼例項Canvas
- jquery和css3實現的動態時鐘效果jQueryCSSS3
- 使用 jQuery 和 CSS3 製作滑動導航選單jQueryCSSS3
- css3繪製跳動的紅心詳解CSSS3
- canvas繪製卡通人臉形象效果Canvas
- 【Matlab 控制】模仿繪製動態影像Matlab
- 笑臉漏洞復現
- css3 繪製畫圓、扇形CSSS3
- CSS3繪製騰訊QQ企鵝CSSS3
- SVG動態繪製不規則圖形SVG
- Chart.js繪製動態折線圖JS
- canvas卡通形象笑臉效果Canvas
- 用CSS3繪製iPhone手機CSSS3iPhone
- 自定義提醒檢視Alert-動態繪製
- CSS3繪製圖形圖案效果CSSS3
- CSS3繪製菱形程式碼例項CSSS3
- svg實現路徑自己動態繪製的功能SVG
- jQuery列表動態增加和刪除jQuery
- css3繪製百度度熊CSSS3
- css3繪製月牙效果程式碼例項CSSS3
- css3繪製燃燒的蠟燭效果CSSS3
- CSS3繪製安卓系統機器人CSSS3安卓機器人
- 玩轉控制元件:GDI+動態繪製流程圖控制元件流程圖
- 基於 D3.js 繪製動態進度條JS
- JQuery1:動態操作HTML和CSSjQueryHTMLCSS
- jQuery動態新增和刪除表格行jQuery
- css3繪製谷歌圖示程式碼例項CSSS3谷歌
- jQuery繪製網格效果程式碼例項jQuery
- Python指令碼檢測笑臉漏洞Python指令碼
- pyqt5+matplotlib繪製動態雙y軸曲線QT
- Kitten 動態繪製 Y 軸方向立方體的實現方法
- CSS3繪製平行四邊形程式碼例項CSSS3
- css3繪製QQ企鵝圖示程式碼例項CSSS3
- css3繪製心形圖案程式碼例項CSSS3
- jquery動態新增和刪除<input type="file" />jQuery
- jQuery動態新增和刪除表格記錄jQuery
- CSS3哭臉效果CSSS3