移动端H5页面阻止图片和文字被选中
1.阻止span标签等文字被选中
在对应元素的css样式中加
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
user-select: none;2.阻止浏览器点击图片查看的行为(常见于uc浏览器)
1.背景图的方式插入(这种是比较普遍的方式)
background:url(./img/tip.png) norepeat center;
background-size: cover;2.使用js事件阻止默认行为的方法
const imgMask = document.getElementById('mask');
imgMask.addEventListener('click', function (event) {
event.stopPropagation();
event.preventDefault();
});本文内容仅供个人学习/研究/参考使用,不构成任何决策建议或专业指导。分享/转载时请标明原文来源,同时请勿将内容用于商业售卖、虚假宣传等非学习用途哦~感谢您的理解与支持!