D
D
darkglare2020-11-16 17:45:46
Bootstrap
darkglare, 2020-11-16 17:45:46

How to position in the center?

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalLong">
  Запустить модальное окно
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>


Hello. Why does the window pop up at the top of the screen and not in the center. I copied the code from the bootstrap page for a modal window that is positioned vertically in the center .5fb29073b4844311207528.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JavaDev, 2020-11-16
@darkglare

Quote from bootsrtap documentation

Add .modal-dialog-centered to .modal-dialog to vertically center the modal.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question