html - 使图像在单击时打开模态?

标签 html css bootstrap-4

图片在 <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">&times;</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/

相关文章:

html - 如何获得带圆 Angular 的边框底线

html - 为列表项元素符号添加背景颜色

html - 如何在工具栏上同时添加图像和文本而不溢出

html - 具有不透明度并覆盖整个屏幕的背景图像

html - 修复了页眉和页脚问题

php - 如果开始时间和结束时间相同,时间选择器返回空值

bootstrap-4 - 如何在 SASS/SCSS 中使用@use 导入和自定义 Bootstrap

html - 行中第一列的样式与其他列不同

com - 如何把IE9的WebBrowser控件纳入标准?

javascript - 2个重叠div上的mousemove事件