当我双击白色背景时,iframe 会突出显示,如何通过 css 禁用它?
https://jsfiddle.net/516y29ka/
要重现,双击白色背景,您将看到 iframe 突出显示。
如何通过CSS禁用它?
<iframe width="642" height="361" src="https://www.youtube.com/embed/M7lc1UVf-VE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Run Code Online (Sandbox Code Playgroud)
user-select: none;在 iframe 上使用。
<!DOCTYPE html>
<head>
<style>
.video-frame {
user-select: none;
}
</style>
<body>
<iframe class="video-frame" width="642" height="361" src="https://www.youtube.com/embed/M7lc1UVf-VE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
几乎所有浏览器都支持它: https: //caniuse.com/?search=user
-select 有关更多信息,请参阅规格:https://www.w3.org/TR/2021/WD-css-ui-4-20210316 /#propdef-用户选择