A recent project involves the functional requirements for handwritten signatures on mobile terminals. The implementation code will be recorded here for your friends’ reference~
HTML code:
<!--Handwriting area--> <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>Handwriting area</p> <canvas id=mSign_signMark_canvas></canvas> </div> </div> </div> </div> <!--Handwriting area end--> <!--Bottom button--> <div class=mSign_signMark_footer> <span id=mSign_signMark_clear_out class=mSign_signMark_footer_cancle>Clear</span> <span id=mSign_signMark_submit class=mSign_signMark_footer_sure>OK</span> </div> <!--Bottom button end-->
CSS style:
.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;}/*Handwritten signature*/.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;}The page introduces JS:
//Handwriting area touch event $(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(); });});Handwritten signature introduction js file address: qianmian-js.rar
The effect is as follows:
The above is the entire content of this article. I hope it will be helpful to everyone’s study. I also hope everyone will support VeVb Wulin Network.