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();
});
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
