大概原理就是
写一个div,宽高同视口,然后固定定位,层级高低看需要
然后使用pointer-events:none;
pointer-events
CSS 属性指定在什么情况下 (如果有) 某个特定的图形元素可以成为鼠标事件的 target
元素永远不会成为鼠标事件的target。但是,当其后代元素的pointer-events
属性指定其他值时,鼠标事件可以指向后代元素,在这种情况下,鼠标事件将在捕获或冒泡阶段触发父元素的事件侦听器。
参考文档:https://developer.mozilla.org/zh-CN/docs/Web/CSS/pointer-events
参考代码如下
pointer-events: none; position: fixed; width: 100%; height: 100%; top: 0px; left: 0px; opacity: 0.382; z-index: 998; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAADICAYAAABS39xVAAAAAXNSR0IArs4c6QAAGyZJREFUeF7tnQuUHUWZx7+vb5hMFBVB42OdR7rvqNnogsEVUFAigiAYRUh4LIKiREVBeay8hIMo8QUiCkgigmgE5Hl4ynODAi6KgCzGqHO7M3NHEKOwi0bnkXR92/+cupybOEOmk5np9OTf53BgZup2Vf2q+J+qr/5fXRU+JEACJFASAlqSdrKZJEACJCAULE4CEiCB0hCgYJVmqNhQEiABChbnAAmQQGkIULBKM1RsKAmQAAWLc4AESKA0BChYpRkqNpQESICCxTlAAiRQGgIUrNIMFRtKAiRAweIcIAESKA0BClZphooNJQESoGBxDpAACZSGAAWrNEPFhpIACVCwOAdIgARKQ4CCVZqhYkNJgAQoWJwDJEACpSFAwSrNULGhJEACFCzOARIggdIQoGCVZqjYUBIgAQoW5wAJkEBpCFCwSjNUbCgJkAAFi3OABEigNAQoWKUZKjaUBEiAgsU5QAIkUBoCFKzSDBUbSgIkQMHiHCABEigNAQpWaYaKDSUBEqBgcQ6QAAmUhgAFqzRDxYaSAAlQsDgHSIAESkOAglWaoWJDSYAEKFicAyRAAqUhQMEqzVCxoSRAAhQszgESIIHSEKBglWao2FASIAEKFucACZBAaQhQsEozVGwoCZAABYtzgARIoDQEKFilGSo2lARIgILFOUACJFAaAhSs0gwVG0oCJEDB4hwgARIoDQEKVmmGig0lARKg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08YAuwwpx6W3TYxAx4x+L5WrFjxjjRNr0CcKwzDg1Ee4olLCbN7vJD/iBsqXpedgO4JPxdWhUEQ4FJCCB5Easdsu4nPXTxcXmSZmRfddgpW0SPA+jeZgE8L+gxuh4iiCCd96zxxHCNF58Js9XNzf3//J6dNmzbHzBBI/0ulUjkqTdOr/CWC2GKufTJv2S1I7g7DcLZfocHs+r1KpXJBmqZ3mNnyRmyrVqvdiHvBvKVibQ5kdjKKK3e2xec3uYN8wXMEKFicDJOCAE4enXMtuF9ruA4lSfIp59wpqvoqf9f84865I9esWdPb0tKyTnDdB9V/7oP73bghwszOjqLoPJ8i9G1VPReufJ9uhNXVLbgfLPvGIDc4OPhQa2vrXli1hWEIhz6fMSJAwRojkHxNeQn4VKBdgyA4CDmP/ss1EPdC3iSSqrH9W3uhYOakx7U2SDs6ENfj+K0lvtYMsS+cXuIeMATxP9F8tU556WxeLadgbV7jwdYUQMDbJmCRQOrP2muesWKq1+vzERNb7y4uJFrj/xtc4fwxmGBFZB/EwqIo+ro/RcR28tne3t63j+bEsoAul7ZKClZph44NH2sCcORnDvq3wtow3JdiIHE6CAL4vHD3/CMwqqZpilXY1s35kUmSnG9mSBPad6Q0obFu+5byPgrWljLS7OcmE/AnhedkloazGl8SO1xw3QfhYYLdO4oifGcjnzEiQMEaI5B8zeQn4AP7+wdBcGXjFlWfUI3rbHBLxBVxHDdSfO6MogjXRPMZQwIUrDGEyVdteQT8iSLMo7BE9HuP1qNmNpdfjDH284GCNfZM+cYtkICPb+1nZo/19fXdzWD7+EwCCtb4cOVbSYAExoEABWscoPKVJEAC40OAgjU+XPlWEiCBcSBAwRoHqHwlCZDA+BCgYI0PV76VBEhgHAhQsMYBKl9JAiQwPgQoWOPDlW8lARIYBwL/D9JLbFC0WwlbAAAAAElFTkSuQmCC) 0px 0px repeat;
标签:none,鼠标,元素,水印,html,0px,pointer,events,css From: https://www.cnblogs.com/zonglonglong/p/18303168