有一个具有内部逻辑的表单 - 当您将鼠标悬停在图像上时,文本会显示在其顶部。
这是通过<input type="image" onClick = this.form.submit>
问题是当您单击鼠标左键时,浏览器将此表单识别为图像,并且当您在新窗口中打开元素时,它会在此处打开图像。必须的形式)
如何解决?旧的逻辑也必须有效 - 当您将鼠标悬停在图像上时,一个元素会出现在它的顶部,当您单击图像时,会提交表单,但是当您单击带有鼠标右键,表单的浏览器菜单出来(在新窗口中打开),而不是图片(在新窗口中打开图片)
<div class="col-3" onmouseover="document.getElementById('@divID').style.display = 'block';" onmouseout="document.getElementById('@divID').style.display = 'none';">
<form asp-action="AddComment" asp-controller="Comments" method="post" enctype="multipart/form-data">
<div class="box maintxt">
<input style="box-shadow: 1px 1px 5px black;" type="image" alt="Submit Form" src="https://previews.123rf.com/images/vera1703/vera17031811/vera1703181100083/114147510-two-green-strips-of-ram-for-a-computer-isolated.jpg" onclick="this.form.submit" class="img-fluid goodBoxShadow rounded" width="175" height="250">
<div id="@divID" style="background-color: red; display: none; pointer-events: none;" class="overlay-text absFullSize">
<div class="mh-100 overflow-hidden border-0 textFade" style="--gradient:linear-gradient(transparent 150px, red);">
<div class="bootstrapp-card-body overflow-hidden border-0" style="background-color: red">
<h11 class="text-left font-italic text-white shadowTextBlack">Текст который появлется при наведении мышкой</h11>
</div>
</div>
</div>
</div>
</form>
</div>

我认为您需要
onContextMenu通过显示菜单来拦截事件并进一步处理它,这是一个代码示例,当onContextMenu我们获取id发生事件的元素以供进一步使用时(包括在上下文菜单中显示,就像我们之前所做的那样显示)。没有菜单创建:
这就是你可以做到的..
使用position: absolute; 和 *z-index: ** ;
对于链接的位置,您可以放置所需的任何内容。
底线是层会有重叠。当你点击图片时,它实际上会被另一层覆盖。z-index上哪个更高:1 或 2...;
好吧,每个有重叠的元素(元素 a,form 的组合)都简单地包装在一个单独的盒子中,其他的以相同的方式包装,然后我们根据需要定位这些盒子。
这是在新选项卡中打开链接的菜单上下文