невозможно изменить положение кнопки закрытия модального окна в bootstrap - PullRequest
1 голос
/ 19 июня 2020

У меня модальное окно bootstrap с кнопкой закрытия, как показано ниже:

<button type="button" id="aloshimandan" class="close" data-dismiss="modal" style="right:7px;position: relative;top:7px;z-index: 1;margin-top:3%;">&times;</button>

кнопка находится внутри модального тела, кнопка появляется немного выше модального окна, я не могу переместить ее вниз. Я попробовал свойство marggin-top и все такое, дал ему важный атрибут, но все равно он даже не двигался. может кто-нибудь подскажите, пожалуйста, что здесь может быть не так, заранее спасибо

1 Ответ

0 голосов
/ 19 июня 2020

Как видите, кнопкой можно легко манипулировать с помощью CSS. Подробнее о Bootstrap 4 модальных окнах здесь https://getbootstrap.com/docs/4.0/components/modal/#live -демонстрация

.modal-content .modal-header .close {
  margin-right: 10px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- needs for bootstrap .popper() -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<!-- bootstrap -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/js/bootstrap.min.js"></script>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">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>
...