Twitter Bootstrap Modal:半屏幕

时间:2015-08-03 09:34:22

标签: javascript jquery html css twitter-bootstrap

我有一个模态,当我启动模态时,它出现在页面顶部的一半切割,因此无法使用,如图所示: http://i.imgur.com/7PcLQCS.png

从图像中可以看出,它离屏幕一半!

这是代码:

   //The button that kick starts the modal magic
<div class="left-trigger" >
   <button class="btn btn-blue" data-toggle="modal" data-target="#supportModal" type="button">Support</button>
</div>
//The modal itself (It's just a series of fields atm for testing :3 )
<div class="modal-scrollable hide" style="z-index: 10050;">
   <div id="supportModal" class="modal hide fade modal-overflow in" tabindex="-1" data-width="760" style="display: block; width: 760px; margin-left: -380px; margin-top: 300px;" aria-hidden="false">
      <div class="modal-header">
         <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
         <h3>Contact Support</h3>
      </div>
      <div class="modal-body">
         <div class="row-fluid">
            <div class="span6">
               <h4>Some Input</h4>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
            </div>
            <div class="span6">
               <h4>Some More Input</h4>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
               <p><input type="text" class="span12 m-wrap"></p>
            </div>
         </div>
      </div>
      <div class="modal-footer">
         <button type="button" class="btn blue">Create My Ticket!</button>
      </div>
   </div>
</div>
//Add a transparent black bg behind the modal... keepin' it pretty!
<div class="modal-backdrop fade in hide" style="z-index: 10049;"></div>

Modal的CSS

.modal {
  position: fixed;
  top: 10%;
  left: 50%;
  z-index: 1050;
  width: 560px;
  margin-left: -280px;
  background-color: #ffffff;
  border: 1px solid #999;
  border: 1px solid rgba(0, 0, 0, 0.3);
  *border: 1px solid #999;
  -webkit-border-radius: 6px;
     -moz-border-radius: 6px;
          border-radius: 6px;
  outline: none;
  -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
     -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
          box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
  -webkit-background-clip: padding-box;
     -moz-background-clip: padding-box;
          background-clip: padding-box;
}

.modal.fade {
  top: -25%;
  -webkit-transition: opacity 0.3s linear, top 0.3s ease-out;
     -moz-transition: opacity 0.3s linear, top 0.3s ease-out;
       -o-transition: opacity 0.3s linear, top 0.3s ease-out;
          transition: opacity 0.3s linear, top 0.3s ease-out;
}

.modal.fade.in {
  top: 10%;
}

.modal-header {
  padding: 9px 15px;
  border-bottom: 1px solid #eee;
}

.modal-header .close {
  margin-top: 2px;
}

.modal-header h3 {
  margin: 0;
  line-height: 30px;
}

.modal-body {
  position: relative;
  max-height: 400px;
  padding: 15px;
  overflow-y: auto;
}

.modal-form {
  margin-bottom: 0;
}

.modal-footer {
  padding: 14px 15px 15px;
  margin-bottom: 0;
  text-align: right;
  background-color: #f5f5f5;
  border-top: 1px solid #ddd;
  -webkit-border-radius: 0 0 6px 6px;
     -moz-border-radius: 0 0 6px 6px;
          border-radius: 0 0 6px 6px;
  *zoom: 1;
  -webkit-box-shadow: inset 0 1px 0 #ffffff;
     -moz-box-shadow: inset 0 1px 0 #ffffff;
          box-shadow: inset 0 1px 0 #ffffff;
}

.modal-footer:before,
.modal-footer:after {
  display: table;
  line-height: 0;
  content: "";
}

.modal-footer:after {
  clear: both;
}

.modal-footer .btn + .btn {
  margin-bottom: 0;
  margin-left: 5px;
}

.modal-footer .btn-group .btn + .btn {
  margin-left: -1px;
}

.modal-footer .btn-block + .btn-block {
  margin-left: 0;
}

所有包含都存在且正确,因为模态功能完全正常。

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

您必须删除display: block;

中的<div id="supportModal"

这将解决您的问题,因为您已使用margin-top: 300px;