admin管理员组

文章数量:1410717

I have a modal and when I launch the modal it's appearing half cut at the top of the page so it can't be used, as shown in the picture : .png

As you can see from the image, it's half off of the screen!

Here's the code:

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

CSS for Modal

.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;
}

All includes are present and correct as the Modal is fully functional.

Thanks for an help in advance.

I have a modal and when I launch the modal it's appearing half cut at the top of the page so it can't be used, as shown in the picture : https://i.sstatic/T59u9.png

As you can see from the image, it's half off of the screen!

Here's the code:

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

CSS for Modal

.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;
}

All includes are present and correct as the Modal is fully functional.

Thanks for an help in advance.

Share edited Nov 9, 2015 at 14:38 Jad Chahine asked Aug 3, 2015 at 9:34 Jad ChahineJad Chahine 7,1999 gold badges40 silver badges64 bronze badges 5
  • 1 Please use inspect element to check if it has a negative top or margin-top. – Rvervuurt Commented Aug 3, 2015 at 9:36
  • online link to check this out?? – Abdulla Nilam Commented Aug 3, 2015 at 9:36
  • I see that your .modal.fade has a top property of -25%. I also remend using Inspect Element to check if you have some negative top/margin-top. – Martin Beentjes Commented Aug 3, 2015 at 9:37
  • 2 Also, // is NOT how you ment out text in HTML. Use <!-- -->. – Rvervuurt Commented Aug 3, 2015 at 9:37
  • provide jsfiddle and your problem will be sorted out – Himesh Aadeshara Commented Aug 3, 2015 at 9:38
Add a ment  | 

1 Answer 1

Reset to default 3

You have to remove display: block; in <div id="supportModal"

This will solve your problem, because you already use margin-top: 300px;

本文标签: javascriptTwitter Bootstrap Modal Half off screenStack Overflow