惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

博客园 - 会走路的虾米

springboot怎样动态加载配置文件 定时任务清除Windows服务器30天以上java系统日志 windows下3主3从的redis5.X集群 windows上的TortoiseSVN迁移到另一台windows上 查看linux内存使用情况的相关命令 pom.xml文件中xmlns作用 linux下安装jdk java中String的3个替换方法(replace,replaceAll,replaceFirst)的区别 把tomcat做成服务模式 解决unable to find valid certification path to requested target windows校验下载文件的md5 冒泡排序法的写法 eclipse中使用maven创建springmvc项目 eclipse中创建简单maven项目,并导出jar包运行 eclipse创建maven模块化web项目 js获取iframe最上层或者上上层的元素值 slf4j下使用log4j myeclipse使用tortoisesvn sl4j日志加traceId
html5图片实现双指拉大
会走路的虾米 · 2025-08-19 · via 博客园 - 会走路的虾米

在html5中,特别是购物商城,或者公司产品图片展示。

由于客户端通常都是移动终端设备,屏幕比较小,于是有通过html5图片实现双指拉大的需求,代码如下。

欢迎评论,谢谢。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Double Finger Zoom Image</title>
    <style>
        #zoomable-image {
            width: 100%; /* 或者设置一个具体的宽度 */
            transition: transform 0.2s; /* 平滑的缩放效果 */
        }
    </style>
</head>
<body>
    <img id="zoomable-image" src="ceshi1.jpeg" alt="Zoomable Image">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            var img = document.getElementById('zoomable-image');
            var mc = new Hammer(img);
            mc.get('pinch').set({ enable: true }); // 启用捏合手势识别
            mc.on('pinch', function(ev) { // 监听pinch事件进行缩放处理
                var scale = ev.scale; // 获取缩放比例,默认是1,即100%大小。大于1放大,小于1缩小。
                img.style.transform = 'scale(' + scale + ')'; // 应用缩放变换到图片上。
            });
        });
    </script>
</body>
</html>