【问题标题】:I tried implementing a modal through the click of an image using Bootstrap but it isn't working我尝试使用 Bootstrap 通过单击图像来实现模式,但它不起作用
【发布时间】:2017-06-14 00:24:38
【问题描述】:

下面是我的写法。请让我知道我在哪里搞砸了。

<img class="img-responsive" src="http://via.placeholder.com/380x300" alt="Appify image" data-toggle="modal" data-taget="#appify">
<div class="modal fade" id="appify" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="appify">APPIFY</h4>
            </div>
            <div class="modal-body">
                <img class="img-responsive" src="http://via.placeholder.com/380x300">
                This is Appify, biatch!
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>

【问题讨论】:

  • 数据目标没有#我认为
  • 你也许可以做一个onClick事件并通过jQuery切换模式?我从未见过从 img 标签切换的模态...
  • 你也错过了一个结局
  • @MinarMnr 非常感谢它现在正在工作。
  • @deckeresq 成功了!我想做一些实验,它奏效了!谢谢!
  • 标签: javascript html twitter-bootstrap image modal-dialog


    【解决方案1】:

    您在img 标签上拼错了data-target。你的版本是data-taget="#appify"&gt;,但应该是data-target="#appify"&gt;

    整个标签: &lt;img class="img-responsive" src="http://via.placeholder.com/380x300" alt="Appify image" data-toggle="modal" data-target="#appify"&gt;

    这是一个有效的小提琴: https://jsfiddle.net/gx00gswh/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-19
      • 1970-01-01
      • 2023-01-30
      • 1970-01-01
      • 2018-11-09
      • 2018-10-03
      • 2021-03-10
      • 1970-01-01
      相关资源
      最近更新 更多