Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

334
Visualizações
how to fix an element in bottom while the keyboard is open

I have a page that has an element at the bottom of the page. I use position absolute to fix it to bottom. When I open the keyboard he element goes to middle of the page.

It's a normal situation 1

I want this second image

And this is my problem third image

.container{
    position:relative;
    height:100%;
}
.myclass{
    position : absolute;
    bottom:0;
    margin:auto;
    display:flex;
    align-items:center;
}
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Using

display:flex;
flex-direction: column;

in your main container

and add your .box element margin-top: auto; will fix your problem i guess.

Press the button

const container = document.querySelector('.container');

const addButton = document.querySelector('button');


addButton.addEventListener('click', () => {
    const newDiv = document.createElement('div');
    newDiv.style.height = "10rem";
    newDiv.style.width = "100%";
    newDiv.style.backgroundColor = "red";
    container.appendChild(newDiv);
})
*, 
*::before,
*::after{
    margin: 0;
}


body{
    min-height: 100vh;
}


.container{
    display: flex;
    flex-direction: column;
    text-align: center;
    width:375px;
    height: 100vh;
    margin: 0 auto;
    background-color: bisque;
}

.box{
    height: 5rem;
    width: 100%;
    background-color: blue;
    margin-top: auto;
}

button{
    position: absolute;
    width: 5rem;
    height: 5rem;
    top: 5rem;
    right: 5rem;
}
<div class="container">
      <h1>Enter text</h1>
      <div class="box"></div>
</div>
<button>Add new box</button>

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda