图片在 <div>
中但是当其中一个被点击时,会出现一个单独的模态,显示已被点击的 div 的信息。模态具有 id 或类,如 modal4
这是我的尝试:
<image type="image" src="Images/Drake.jpg" data-target="modal" data-toggle="#modal4" style="width:130px;height:140px;margin-left:10px;margin-bottom:10px"/> </a>
这是我的模态代码:
<div class="modal" id="Modal4" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Aubrey Drake "Drizzy" Graham</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
</div>
</div>
</div>
最佳答案
可能是因为您在图片标签中指的是所有小写的模态 ID,而实际模态 ID 的大写字母是 M?
在 img 标签中:
data-toggle="#modal4"
在模态声明中:
id="Modal4"
到处匹配案例以确保。
关于html - 使图像在单击时打开模态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58500268/