-webkit-touch-callout

本文介绍了如何使用CSS的-webkit-touch-callout属性来控制在触摸设备上按住元素时是否显示系统默认菜单。通过设置此属性为'none',你可以阻止Safari浏览器等应用在触摸操作时弹出额外的菜单,从而提供更纯净的用户体验。

-webkit-touch-callout

当你触摸并按住触摸目标时候,禁止或显示系统默认菜单。在iOS上,当你触摸并按住触摸的目标,比如一个链接,Safari浏览器将显示链接有关的系统默认菜单。这个属性可以让你禁用系统默认菜单。

.mobile-carousel { width: 100vw; height: 100vh; overflow: hidden; position: fixed; top: 0; left: 0; margin: 0; padding: 0; z-index: 1000; touch-action: pan-y; background: #000; } .slides { display: flex; height: 100%; transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1); /* 更顺滑的缓动函数 */ } .slide { flex: 0 0 100vw; /* 宽度精确匹配视口 / position: relative; height: 100vh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-sizing: border-box; / 包含内边距 */ } .slide img { width: 100%; height: 100%; object-fit: cover; display: block; /* 防止长按菜单 */ pointer-events: none; -webkit-touch-callout: none; } .slide-hint { position: absolute; bottom: calc(10vh + env(safe-area-inset-bottom)); /* 避开底部安全区域 / right: max(5vw, env(safe-area-inset-right)); / 适配刘海屏 / background: rgba(0,0,0,0.75); color: #fff; padding: 12px 20px; border-radius: 30px; font-size: 16px; animation: hintPulse 1.5s infinite; backdrop-filter: blur(4px); / 毛玻璃效果 */ z-index: 10; font-weight: 500; } @keyframes hintPulse { 0% { opacity: 0.7; transform: translateX(0) scale(0.98); } 50% { opacity: 1; transform: translateX(-8px) scale(1.03); } 100% { opacity: 0.7; transform: translateX(0) scale(0.98); } } /* 全面屏适配 / @media screen and (max-aspect-ratio: 9/16) { .slide img { object-fit: contain; / 超长屏使用contain模式 */ } } /* 禁用iOS橡皮筋效果 */ body { overscroll-behavior: none; } 为什么屏幕顶部和底部会有一块黑色背景区域 我希望有这个区域 我希望图片占据整个屏幕,并且希望有安全区域
最新发布
09-21
.mobile-carousel { width: 100vw; height: 100vh; overflow: hidden; position: fixed; top: 0; left: 0; margin: 0; padding: 0; z-index: 1000; touch-action: pan-y; background: #000; } .slides { display: flex; height: 100%; transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1); /* 更顺滑的缓动函数 */ } .slide { flex: 0 0 100vw; /* 宽度精确匹配视口 */ position: relative; height: 100vh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-sizing: border-box; /* 包含内边距 */ } .slide img { width: 100%; height: 100%; object-fit: cover; display: block; /* 防止长按菜单 */ pointer-events: none; -webkit-touch-callout: none; } .slide-hint { position: absolute; bottom: calc(10vh + env(safe-area-inset-bottom)); /* 避开底部安全区域 */ right: max(5vw, env(safe-area-inset-right)); /* 适配刘海屏 */ background: rgba(0,0,0,0.75); color: #fff; padding: 12px 20px; border-radius: 30px; font-size: 16px; animation: hintPulse 1.5s infinite; backdrop-filter: blur(4px); /* 毛玻璃效果 */ z-index: 10; font-weight: 500; } @keyframes hintPulse { 0% { opacity: 0.7; transform: translateX(0) scale(0.98); } 50% { opacity: 1; transform: translateX(-8px) scale(1.03); } 100% { opacity: 0.7; transform: translateX(0) scale(0.98); } } /* 全面屏适配 */ @media screen and (max-aspect-ratio: 9/16) { .slide img { object-fit: contain; /* 超长屏使用contain模式 */ } } /* 禁用iOS橡皮筋效果 */ body { overscroll-behavior: none; } 为什么屏幕顶部和底部会有一块黑色背景区域 我希望有这个区域 我希望图片占据整个屏幕
09-21
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值