[英]Use Chrome Dev Tools to overlay transparent Image in Browser window
I am looking for a way to overlay an Image over the current page I am viewing with the chrome dev tools.我正在寻找一种方法来将图像覆盖在我正在使用 chrome 开发工具查看的当前页面上。 The overlay needs to be transparent and I must be able to interact with the page below the image layer.叠加层需要是透明的,我必须能够与图像层下方的页面进行交互。
Is that possible?那可能吗? It would be best, if I could paste a URL to the image with the rest of the code.如果我可以使用代码的 rest 将 URL 粘贴到图像中,那将是最好的。
Thanks for your help:)谢谢你的帮助:)
Yes, it is possible.是的,有可能。 The CSS property you are looking for is pointer-events: none
.您要查找的 CSS 属性是pointer-events: none
。
function addOverlayImage(src, opacity) {
const img = new Image();
img.src = src;
Object.assign(img.style, {
position: 'fixed',
left: 0,
top: 0,
width: '100vw',
height: '100vh',
opacity,
objectFit: 'cover',
objectPosition: 'center center',
pointerEvents: 'none'
});
document.body.appendChild(img);
}
Usage:用法:
addOverlayImage('https://i.picsum.photos/id/1/1440/900.jpg', 0.5);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.