最近項(xiàng)目中涉及到移動(dòng)端手寫簽名的功能需求,將實(shí)現(xiàn)代碼記錄于此,供小伙伴們參考指摘哦~
HTML代碼:
<!--手寫區(qū)--> <div class="mSign_signMark_box"> <div class="mSign_signMark_write_box"> <div id="mSign_signMark_signature_pad" class="mSign_signMark_body_box"> <div class="mSign_signMark_body"> <span class="mSign_signMark_clear_out"> <img src="../images/mCommon_basicIcon_deleteRed.png"> </span> <p>手寫區(qū)</p> <canvas id="mSign_signMark_canvas"></canvas> </div> </div> </div> </div> <!--手寫區(qū) end--> <!--底部按鈕--> <div class="mSign_signMark_footer"> <span id="mSign_signMark_clear_out" class="mSign_signMark_footer_cancle">清除</span> <span id="mSign_signMark_submit" class="mSign_signMark_footer_sure">確定</span> </div> <!--底部按鈕 end-->
CSS樣式:
.mSign_signMark_box{padding: 15px 15px 26px 15px;} .mSign_signMark_footer{max-width:640px;margin:0 auto;height: 44px;background: #4ba7eb;position: fixed;bottom: 0;left: 0;right: 0;color:#fff;font-size: 16px;text-align: center;line-height: 44px;} .mSign_signMark_footer span{display: block;width: 50%;text-align: center;float: left;} .mSign_signMark_footer_cancle{background: #f4f4f5;color: #333333;} /*手寫簽名*/ .mSign_signMark_write_box{position: relative;height: 240px;} .mSign_signMark_body_box {position: absolute;background-color: #fff;border: 1px solid #ccc;top:0;left: 0;right: 0;bottom: 0;width: 99%;height: auto;min-width: 250px;min-height: 140px;} .mSign_signMark_body {position: absolute;left: 0;right: 0;top: 0;bottom: 0;} .mSign_signMark_body canvas {position: absolute;left: 0;top: 0;width: 100%;height: 100%;} .mSign_signMark_body p{position: absolute;font-size: 14px;color: #ccc;text-align: center;width: 100%;top: 50%;margin-top: -22px;} .mSign_signMark_clear_out{position: absolute;top:-10px;right: -5px;z-index: 10;display: none;} .mSign_signMark_clear_out img{width: 18px;height: 18px;}
頁(yè)面引入JS:
//手寫區(qū)觸摸事件 $(function() { var ctouch=$('.mSign_signMark_body canvas'); ctouch.bind("touchstart",function(event){ $('.mSign_signMark_body p').hide(); }); ctouch.mouseover(function(event) { $('.mSign_signMark_body p').hide(); }); });
手寫簽名引入js文件地址:qianmian-js_jb51.rar
實(shí)現(xiàn)效果如下:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
標(biāo)簽:蚌埠 阿克蘇 果洛 廣東 鄂爾多斯 廣西 常德 松原
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《canvas畫布實(shí)現(xiàn)手寫簽名效果的示例代碼》,本文關(guān)鍵詞 canvas,畫布,實(shí)現(xiàn),手寫,簽名,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。