温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用canvas怎么实现一个手写签名效果

发布时间:2021-04-07 15:41:52 阅读:324 作者:Leah 栏目:web开发
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

这期内容当中小编将会给大家带来有关使用canvas怎么实现一个手写签名效果,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

HTML代码:

<!--手写区-->
        <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>手写区</p>
                        <canvas id="mSign_signMark_canvas"></canvas>
                    </div>
                </div>
            </div>
        </div>
        <!--手写区 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{padding15px 15px 26px 15px;}
.mSign_signMark_footer{max-width:640px;margin:0 auto;height44px;background#4ba7eb;position: fixed;bottom0;left0;right0;color:#fff;font-size16px;text-align: center;line-height44px;}
.mSign_signMark_footer span{display: block;width50%;text-align: center;float: left;}
.mSign_signMark_footer_cancle{background#f4f4f5;color#333333;}
/*手写签名*/
.mSign_signMark_write_box{position: relative;height240px;}
.mSign_signMark_body_box {position: absolute;background-color#fff;border1px solid #ccc;top:0;left0;right0;bottom0;width99%;height: auto;min-width250px;min-height140px;}
.mSign_signMark_body {position: absolute;left0;right0;top0;bottom0;}
.mSign_signMark_body canvas {position: absolute;left0;top0;width100%;height100%;}
.mSign_signMark_body p{position: absolute;font-size14px;color#ccc;text-align: center;width100%;top50%;margin-top: -22px;}
.mSign_signMark_clear_out{position: absolute;top:-10px;right: -5px;z-index10;display: none;}
.mSign_signMark_clear_out img{width18px;height18px;}

页面引入JS:

//手写区触摸事件
$(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();
    });
});

上述就是小编为大家分享的使用canvas怎么实现一个手写签名效果了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

原文链接:https://www.jb51.net/html5/669271.html

AI

开发者交流群×