Centralizing modal bootstrap on mobile screen

Asked

Viewed 1,257 times

2

I’m trying to centralize a modal bootstrap in the center of a mobile screen, but the result is the following:

inserir a descrição da imagem aqui

I’m following this example, but it’s not working:

How to Center a Modal Box Horizontally and Vertically with CSS3? Possible?

Below the codes of my modal and CSS:

<div id="modal-facens" class="modal fade" role="dialog">
    <div class="modal-dialog" role="document">
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <h4 class="modal-title">FACENS - Faculdade de Engenharia de Sorocaba</h4>
          <i class="fa fa-map-marker" aria-hidden="true"></i> Sorocaba/SP <br>
          <a href="http://www.facens.br/" target="_blank">http://www.facens.br/</a>
        </div>
        <div class="modal-body">
            <p>
                Cursando o último ano de Engenharia da Computação. Teste Commit. Teste Commit DEV
            </p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn-info btn-sm" data-dismiss="modal">Fechar</button>
        </div>
      </div>
    </div>
  </div>

.modal {
  text-align: center;
}
@media screen and (min-width: 768px) {
  .modal:before {
    display: inline-block;
    vertical-align: middle;
    content: " ";
    height: 100%;
  }
}
.modal-dialog {
  display: inline-block;
  text-align: left;
  vertical-align: middle;
}

1 answer

3


Solved.

I changed the CSS code with the contents below:

.modal {
  text-align: center;
  padding: 0!important;
}

.modal:before {
  content: '';
  display: inline-block;
  height: 100%;
  vertical-align: middle;
  margin-right: -4px;
}

.modal-dialog {
  display: inline-block;
  text-align: left;
  vertical-align: middle;
}

The result I wanted:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.