html - 如何在 iPhone 上按下按钮时摆脱恼人的灰色高光效果
问题描述
我有以下非常基本的HTML
代码:
<html>
<head>
<meta charset="UTF-8">
<style type="text/css">
* {
outline: none;
}
a {
padding: 6px 20px;
border: 1px solid #bdbdbd;
border-radius: 6px;
text-decoration: none;
font-size: 100px;
}
a:active {
box-shadow: 0px 0px 4px 0px #b9b9b9;
-webkit-box-shadow: 0px 0px 4px 0px #b9b9b9;
}
</style>
<title>IPhone - Button</title>
</head>
<body>
<a href="#">Long Press This</a>
</body>
</html>
当我在真实IPhone
设备上打开它时,我得到以下信息:
但是当我长按按钮时,我得到以下信息:
带有非常烦人的灰色突出背景。
我只在 iPhone 上得到那种烦人的效果。我在其他浏览器(Android、Windows、MacOS)上尝试了同样的方法,但没有得到那种效果。
关于如何摆脱它的任何想法?
在这里,您有代码的内联演示:
* {
outline: none;
}
a {
padding: 6px 20px;
border: 1px solid #bdbdbd;
border-radius: 6px;
text-decoration: none;
font-size: 40px;
}
a:active {
box-shadow: 0px 0px 4px 0px #b9b9b9;
-webkit-box-shadow: 0px 0px 4px 0px #b9b9b9;
}
<a href="#">Long Press This</a>
请注意,我需要在box-shadow
上面同时摆脱灰色突出显示。换句话说,我需要在其他浏览器上获得相同的效果。
它也在这里JSFiddle.net
:
http://jsfiddle.net/05kqt7m3/embedded/result/
谢谢!
解决方案
你有没有尝试过:
<style type="text/css">
* {
-webkit-touch-callout: none;
-webkit-user-select: none; /* Disable selection/copy in UIWebView */
}
</style>
推荐阅读
- python-3.x - 如何使分组的熊猫 DataFrage 的所有行都满足特定条件?
- angular - 如何在模板中访问,反应形式,数组中的数组
- swift - 在swift中的自定义标题中获取具有文件大小的下载文件的进度
- javascript - 从特定过滤器获取信息
- azure-devops - 是否可以编辑选项 ==> Azure DevOps 中字段的默认值
- algorithm - 分而治之解决数字的力量,使用主定理进行运行时分析
- python - 我有一个列表列表,如何提取具有共同值的子列表的索引?
- javascript - Vuetify v-select 问题
- transactions - contract.evaluateTransaction(fcn,args) 在查询背书节点时是否进行交易?
- python - 不要在 Python 3 中转义字符串