canvas画布实现手写签名效果的示例代码
作者:互联网
2025-07-29
最近项目中涉及到移动端手写签名的功能需求,将实现代码记录于此,供小伙伴们参考指摘哦~
HTML代码:
![]()
手写区
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;}页面引入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(); });}); 手写签名引入js文件地址:qianmian-js.rar
实现效果如下:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持本站。
注:相关教程知识阅读请移步到HTML教程频道。
相关标签:
HTML教程
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
WebSocket 连接池生产级实现:实时行情高可用与负载均衡
04/18
使用 Python 合并与拆分 Excel 单元格的实用方法
04/18
Pandas数据清洗完整指南:8大核心技巧详解
04/17
NumPy+Pandas数据分析基础完全指南
04/17
AI Agent 接入 Zvec (一):MCP 篇
04/17
python 更新Obsidian
04/17
用Manim实现动态交点计算--从一个动点问题说起
04/17
用 AI 解决数据库性能问题的方法论
04/17
前端害怕被蒸馏 快速入门Python 【demo_03】
04/17
Python 操作 Word 文档节与页面设置
04/16
AI精选
