我尝试使用Bootstrap通过单击图像来实现模态,但它不起作用

时间:2017-06-13 16:19:16

标签: javascript html twitter-bootstrap image modal-dialog

以下是我写的方式。请让我知道我搞砸了。

<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>

1 个答案:

答案 0 :(得分:2)

data-target标记上的拼写错误img。您的版本为data-taget="#appify">,但应为data-target="#appify">

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

这是一个工作小提琴: https://jsfiddle.net/gx00gswh/