同一页面上有多个Bootstrap模式

时间:2015-10-06 15:26:21

标签: css twitter-bootstrap modal-dialog

我正在研究http://steam-to-rent.ch/mietdampfanlagen.html。如您所见,我正在使用 Bootstrap collapse ,当您点击“Anfrage”按钮时,它会显示 Bootstrap的模态。问题是当你点击第二个“模态按钮”( Anfrage )然后你关闭那个模态后,背景覆盖颜色仍然存在,我无法与页。我该如何解决?

这是代码

<button type="button" class="btn btn-primary special"
    style="background: #fadf3e; border: 2px solid #000; color: #000; margin-bottom: 20px; margin-top: -10px; width: 100%;"
    data-toggle="modal"
    data-target=".bs-example-modal-sm">Anfrage</button>

<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
        <h4 style="color: #000;">Mietdampfanlage 21 kg/h 10 bar</h3>
         <div class="col-sm-12 form">
             <form class="form-modal" role="form" method="post" action="index.php">
        <div class="form-group" style="margin-bottom: 15px !important;">      
            <div class="col-sm-12">
                <input type="text" class="form-control" id="name" name="name" placeholder="Vorname, Name" value="">
            </div>
        </div>
        <div class="form-group"  style="margin-bottom: 15px !important;">
            <div class="col-sm-12 ">
                <input type="text" class="form-control" id="name" name="firma" placeholder="Firma" value="">
            </div>
        </div>
        <div class="form-group"  style="margin-bottom: 15px !important;">
            <div class="col-sm-12 ">
                <input type="email" class="form-control" id="email" name="email" placeholder="E-Mail" value="">
            </div>
        </div>
        <div class="form-group" style="margin-bottom: 15px !important;">
            <div class="col-sm-12">
                <input type="text" class="form-control" id="name" name="telefon" placeholder="Telefon" value="">
            </div>
        </div>

        <div class="form-group" style="margin-bottom: 15px !important;">
            <div class="col-sm-12">
                <input type="text" class="form-control" id="name" name="zeit" placeholder="Zeitraum" value="">
            </div>
        </div>

        <div class="form-group"  style="margin-bottom: 15px !important;">
           <div class="col-sm-12">
                <textarea class="form-control" rows="4" name="message" placeholder="Nachricht"></textarea>
            </div>
        </div>
        <div class="form-group"  style="margin-bottom: 15px !important;">
            <div class="col-sm-12">
                <input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
            </div>
        </div>
        <div class="form-group"  style="margin-bottom: 15px !important;">
            <div class="col-sm-10 col-sm-offset-2">
                <! Will be used to display an alert to the user>
            </div>
        </div>
    </form></div>
    </div>
  </div>
</div>

编辑:

 <button id="modal_1" type="button" class="btn btn-primary special" style="background: #fadf3e; border: 2px solid #000; color: #000; margin-bottom: 20px; margin-top: -10px; width: 100%;" data-toggle="modal" data-target=".bs-example-modal-sm">Anfrage</button>
    <div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="row">
             <div class="col-sm-12 form">
                 <div class="modal-header">
                 <h4 style="color: #000;">Mietdampfanlage 21 kg/h 10 bar</h4>
                 </div>     
                        <form class="form-modal" role="form" method="post" action="index.php">
            <div class="col-sm-12">               
            <div class="form-group">
                    <input type="text" class="form-control" id="name" name="name" placeholder="Vorname, Name" value="">
                </div>
            </div>
                         <div class="col-sm-12">    
                         <div class="form-group">
                    <input type="text" class="form-control" id="name" name="firma" placeholder="Firma" value="">
                </div>
            </div>

            <div class="col-sm-12 ">                 
            <div class="form-group">
                    <input type="email" class="form-control" id="email" name="email" placeholder="E-Mail" value="">
                </div>
            </div>

                <div class="col-sm-12 ">
                <div class="form-group">
                    <input type="text" class="form-control" id="name" name="telefon" placeholder="Telefon" value="">
                </div>
            </div>

                <div class="col-sm-12 ">             
                <div class="form-group">
                    <input type="text" class="form-control" id="name" name="zeit" placeholder="Zeitraum" value="">
                </div>
            </div>

            <div class="col-sm-12 ">                 
            <div class="form-group">
                    <textarea class="form-control" rows="4" name="message" placeholder="Nachricht"></textarea>
                </div>
            </div>

            <div class="col-sm-12 ">                 
            <div class="form-group">
                    <input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
                </div>
            </div>
            <div class="form-group"  style="margin-bottom: 15px !important;">
                <div class="col-sm-10 col-sm-offset-2">
                    <! Will be used to display an alert to the user>
                </div>
            </div>
        </form></div>
        </div>
          </div>
      </div>
    </div>

1 个答案:

答案 0 :(得分:-1)

data-backdrop="static" 
data-keyboard="false"

首先查看是否有data-backdrop =“Static”。那样做会。还要确保数据键盘不是假的,只是为了确保您可以进行交互。

最后我想让你看看按钮和模态上的ID。确保它们都不同。我在这里看不到这个模态的ID,所以我建议像

id="modal_1"

按钮和模态。确保它匹配