Bootstrap模式与引导卡无法正常工作

时间:2015-01-07 09:46:59

标签: html css twitter-bootstrap modal-dialog z-index

Bootcard modal disappears on click我使用这个模态和bootstrap:

<div class="modal" id="contact-update-view">
                <div class="modal-dialog">
                    <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">Update contact</h4>                
                        </div>
                        <form class="form-horizontal">
                            <div class="modal-body">
                                <div class="form-group">
                                    <label for="contact-create-name" class="col-sm-4  control-label">Name</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <div class="input-group-addon">
                                                <span class="glyphicon glyphicon-user"></span>
                                            </div>
                                            <input type="text" class="form-control" id="contact-create-name" name="contact-create-name" data-minlength="2" placeholder="Contact's Name" data-error="Name should atleast be 2 characters long" required />
                                            <div class="help-block with-errors"></div>    
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="contact-create-phone" class="col-sm-4  control-label">Phone</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <div class="input-group-addon">
                                                <span class="glyphicon glyphicon-phone"></span>
                                            </div>
                                            <input type="tel" class="form-control" id="contact-create-phone" name="contact-create-phone" placeholder="Phone Number" pattern="^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$"  data-error="Enter a valid phone number" required/>   
                                            <div class="help-block with-errors"></div> 
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="contact-create-email" class="col-sm-4  control-label">Email</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <div class="input-group-addon">
                                                <span class="glyphicon glyphicon-envelope"></span>
                                            </div>
                                            <input type="email" class="form-control" id="contact-create-email" name="contact-create-email" placeholder="Email" required data-error="The email is invalid"/>  
                                            <div class="help-block with-errors"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <div class="form-group">
                                    <div class="col-sm-offset-4 col-sm-8">
                                      <button type="submit" class="btn btn-success" data-toggle="tooltip" title="Yep! Two exclamations and a question mark,arent you excited?">Add contact!</button>
                                    </div>
                                </div>    
                            </div>
                        </form>    
                    </div>
                </div>
            </div>

我使用bootcards-desktop.css from here,我发现背景显示在modal上方。当我点击模态时,它会立即被解雇。

我用这个打开模态:

 <button type="button" class="btn btn-default btn-edit" data-toggle="modal" data-target="#contact-update-view">
    <span class="glyphicon glyphicon-pencil"></span>
 </button>

我在css中看到了这种差异:

.modal
        z-index:1050;
        position:fixed;

   .modal-backdrop:
       position:fixed;
       z-index:1040;   

当我点击模态时,它会消失(好像模态顶部有一个背景),如何让模态与bootcards一起正常工作?

1 个答案:

答案 0 :(得分:1)

这不是Bootstrap 3.3.1问题,也不是Bootcards问题。问题出在设置中:bootcards-desktop.min.css文件(以及Android和iOS版本)是Bootstrap(目前为v3.2.0)以及Bootcards CSS文件的连接版本。这是提供的,因此您可以减少一个HTTP请求。在Bootcards下载的dist文件夹中,您还可以找到没有内置Bootstrap的CSS文件版本:它们后缀为-lite(并且要小得多......)。

在您的Plunkr中,如果我将Bootstrap版本更改为v3.3.1并将bootcards-desktop.min.css更改为bootcards-desktop-lite.min.css,则一切都可以正常工作。

我将很快发布另一个版本的Bootcards,它将扩展Bootstrap v3.3.1。