【问题标题】:Bootstrap Modal: make the whole columns clickableBootstrap Modal:使整个列可点击
【发布时间】:2017-07-17 21:53:25
【问题描述】:

我正在website 上测试一些模态窗口,正如您现在看到的那样,模态在点击/触摸播放按钮时切换。

我的问题是:是否可以使整个列可点击并打开模式?

我还尝试使用数据目标为整个 div 定义一个数据切换,但没有任何结果。

这是 HTML 代码:

<!-- Button trigger modal -->
<i class="fa fa-play btn btn-lg" aria-hidden="true" type="button" data-toggle="modal" data-target="#myModal"></i>
</div>
<!-- Modal -->
<div class="modal fade modal-video" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
 <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title" id="myModalLabel">Title 1</h4>
  </div>
  <div class="modal-body">
      <video controls="" width="100%" id="video">
      <source src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" type="video/mp4">
      </video>
      <div class="modal-text">
          <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr.</p>
      </div>
  </div>
  <div class="modal-footer">
    <button type="button" class="btn button-eh-magenta">Go to Shop</button>
    <a href=""><button type="button" class="btn button-eh-magenta">Share</button></a>
  </div>
</div>

【问题讨论】:

    标签: css twitter-bootstrap modal-dialog bootstrap-modal


    【解决方案1】:

    您可以为您的 div 分配一个 id,然后单击该打开模式并执行以下操作:

    $('#specified_div').click(function(){
        $('#targetmodal').modal();
    });
    

    另一种方法是添加data-toggle="modal"data-target="#targetmodal" 到您想要的任何元素,方法是单击id 为targetmodal 打开的元素模式。


    这里是引导站点报价:

    通过数据属性

    无需编写 JavaScript 即可激活模式。设置data-toggle="modal" 在一个控制器元素上,比如一个按钮,以及一个 data-target="#foo"href="#foo" 将特定模式定位到 切换。

    <button type="button" data-toggle="modal" data-target="#myModal">Launch modal</button>
    

    通过 JavaScript

    使用单行 JavaScript 调用 id 为 myModal 的模式:

    $('#myModal').modal(options)
    

    【讨论】:

    • 嗨,我已经尝试将 data-toggle 和 data-target 分配给 div,但结果是无法关闭模式。
    • 没有错误。你可以看看,我已经按照你的建议申请了数据目标和数据切换的第一列。碰巧模态不会关闭。 cms.nowcommu.myhostpoint.ch
    • 从内部 col-md-6 div codepen.io/poursadeqi/pen/qjwGqG?editors=1010 中移出您的模态 div 我从内部 div 中提取您的代码并在 div 上设置数据属性的代码在哪里,它可以正常工作(当然我只是将它设置为红色 div :D @Roxana)
    猜你喜欢
    • 2016-01-30
    • 2021-08-30
    • 2015-10-20
    • 2016-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-12
    相关资源
    最近更新 更多