右键单击图像时显示此内容

我尝试创建一个网站来显示带有图像的每个产品,但我想禁止用户下载图像的产品,当用户右键单击它时,他/她无法下载它或打开图像要下载新选项卡,我想显示下图中出现的 这个框。

https://img1.sycdn.imooc.com/656db66e0001645e06450314.jpg

开满天机
浏览 41回答 1
1回答

胡子哥哥

像这样覆盖你的图像<!DOCTYPE html><html><head>&nbsp; <title>some title</title>&nbsp; <style>&nbsp; &nbsp; * {&nbsp; &nbsp; &nbsp; box-sizing: border-box;&nbsp; &nbsp; }&nbsp; &nbsp; .img-container {&nbsp; &nbsp; &nbsp; width: 300px;&nbsp; &nbsp; &nbsp; height: 200px;&nbsp; &nbsp; &nbsp; position: relative;&nbsp; &nbsp; }&nbsp; &nbsp; .img-container img, .img-container .img-cover {&nbsp; &nbsp; &nbsp; width: 100%;&nbsp; &nbsp; &nbsp; height: 100%;&nbsp; &nbsp; }&nbsp; &nbsp; .img-container .img-cover {&nbsp; &nbsp; &nbsp; position: absolute;&nbsp; &nbsp; &nbsp; top: 0;&nbsp; &nbsp; &nbsp; left: 0;&nbsp; &nbsp; }&nbsp; </style></head><body>&nbsp; <div class="img-container">&nbsp; &nbsp; <img src="your_image.png">&nbsp; &nbsp; <div class="img-cover"></div>&nbsp; </div></body></html>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5