1

Galera, tenho este código em css para o Login. O que acontece é que deve ter algum erro porque fico com um espaçamento enorme na parte inferior do ecrã. inserir a descrição da imagem aqui

Deixo com vocês o meu código

    <style>

/* Full-width input fields */
input[type=text], input[type=password] {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    display: inline-block;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

.inicioenter{
  position: absolute;
  left: 35%;
  top: 35%
}

/* Set a style for all buttons */
button {
    background-color: #4CAF50;
    color: white;
    padding: 14px 20px;
    margin: 8px 0;
    border: none;
    cursor: pointer;
    width: 100%;
}

button:hover {
    opacity: 0.8;
}

/* Center the image and position the close button */
.imgcontainer {
    text-align: center;
    margin: 24px 0 12px 0;
    position: relative;
}

img.avatar {
    width: 20%;
    border-radius: 20%;
}

.container {
    padding: 13px;
}

span.psw {
    float: right;
    padding-top: 16px;
}

/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    padding-top: 30px;
}

/* Modal Content/Box */
.modal-content {
    background-color: #fefefe;
    margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */
    border: 1px solid #888;
    width: 50%; /* Could be more or less, depending on screen size */
}

/* The Close Button (x) */
.close {
    position: absolute;
    right: 25px;
    top: 0;
    color: #000;
    font-size: 35px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: red;
    cursor: pointer;
}

/* Add Zoom Animation */
.animate {
    -webkit-animation: animatezoom 0.6s;
    animation: animatezoom 0.6s
}

@-webkit-keyframes animatezoom {
    from {-webkit-transform: scale(0)} 
    to {-webkit-transform: scale(1)}
}

@keyframes animatezoom {
    from {transform: scale(0)} 
    to {transform: scale(1)}
}

/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
    span.psw {
       display: block;
       float: none;
    }
    .cancelbtn {
       width: 100%;
    }
}
</style>

O HTML que estou a utilizar:

    <body>

    <div class="inicioenter">
        <center><h2>Iniciar Sessão</h2>
        <button onclick="document.getElementById('boxmodal').style.display='block'" style="width:auto;">Entrar</button></center>

    </div>

    <div id="boxmodal" class="modal">
      <form class="modal-content animate"  method="post">
        <div class="imgcontainer">
          <span onclick="document.getElementById('boxmodal').style.display='none'" class="close" title="Close Modal">&times;</span>
          <img src="img\profile-image.png" alt="Avatar" class="avatar">
        </div>

        <div class="container">
          <label for="uname" class="center-align"><b>Username</b></label>  
          <input id="username" type="text"  name="username" class="validate" autocomplete="off" required>

          <label for="password" class="center-align"><b>Password</b></label>
          <input id="password" type="password" class="validate" name="password" autocomplete="off" required>

          <div class="container2">
            <input type="submit" name="signin" value="Entrar" class="btn waves-effect waves-light">
          </div>


        </div>  
      </form>
    </div>

<!-- Abrir caixa de Login -->
<script>
      // Get the modal
      var modal = document.getElementById('boxmodal');

      // When the user clicks anywhere outside of the modal, close it
      window.onclick = function(event) {
          if (event.target == modal) {
              modal.style.display = "none";
          }
      }
</script>

<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>

</body>
</html>
6
  • Não deu para entender o que acontece! O login é um modal e você quer abri-lo no meio da tela é isto?
    – LeAndrade
    8/09/2018 às 19:05
  • Coloque também o HTML na pergunta ok
    – hugocsl
    8/09/2018 às 20:05
  • Além de colocar o HTML da tela, informe também a versão do Bootstrap que está usando.
    – Sam
    8/09/2018 às 22:13
  • @LeAndrade Sim, o que acontece é que a box do login fica até meio da página. A parte inferior não aparece nada (parte rodeada a vermelho). e eu queria centrar no meio da página
    – fff
    8/09/2018 às 22:41
  • @sam Já adicionei. Estou a utilizar materialize.
    – fff
    8/09/2018 às 22:43

1 Resposta 1

0

O Materialize está definindo o height máximo da modal em 70% da tela, por isso o espaço vazio abaixo.

inserir a descrição da imagem aqui

Redefina o max-height na classe .modal em 100%, ou um valor que anule o valor definido pelo Materialize de 70% (none, ou inherit):

/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    padding-top: 30px;
    max-height: 100%; /* 100%, none ou inherit */
}
4
  • Muito obrigado, ficou resolvido.
    – fff
    8/09/2018 às 22:54
  • De nada amigo! Na verdade, basta anular o valor de 70% do Materialize. Tanto faz colocar 100%, none ou inherit. Abs!
    – Sam
    8/09/2018 às 23:00
  • Salvou o meu login ;) muito obrigado
    – fff
    8/09/2018 às 23:05
  • pode por favor ver se me consegue ajudar nessa outra dificuldade: pt.stackoverflow.com/questions/328318/… obrigado
    – fff
    9/09/2018 às 15:04

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .