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

218
Visualizações
The cursor is hidden by 'position: sticky' element

I have a div anchored to the top of the page using "position: sticky", also have a div below which is editable (contenteditable="true") and it has lots of lines.

Please see the code snippet below:

.scrollable {
  padding: 0.5em;
  box-sizing: border-box;
}

.top {
    position: sticky;
    top: 0;
    z-index: 2;
      background-color: yellow;
}
<html>
<body>

<div class="top">
    sticky line<br/>
    sticky line<br/>
    sticky line<br/>
    sticky line<br/>
    sticky line<br/>
    sticky line<br/>
    sticky line<br/>
    sticky line<br/>
    sticky line<br/>
    sticky line<br/>
    sticky line<br/>
    sticky line<br/>
</div>

<div contenteditable="true" class="scrollable" data-placeholder="Click here to type">
the first line<br/>
ds<br/>
fsd<br/>
f<br/>
dfsd<br/>
ds<br/>
fsd<br/>
f<br/>
dfsd<br/>
ds<br/>
fsd<br/>
f<br/>
dfsd<br/>
ds<br/>
fsd<br/>
f<br/>
dfsd<br/>
ds<br/>
fsd<br/>
f<br/>
dfsd<br/>
ds<br/>
fsd<br/>
f<br/>
dfsd<br/>
ds<br/>
fsd<br/>
f<br/>
dfsd<br/>
ds<br/>
fsd<br/>
f<br/>dfsd<br/>
ds<br/>
fsd<br/>
f<br/>
dfsd<br/>
ds<br/>
fsd<br/>
the last line<br/>
</div>

If I use arrow Down in keyboard to move cursor to the very bottom, then use arrow UP in keyboard to move the cursor all the way up, the cursor will eventually move into the top div area and thus be hidden, making typing invisible.

What I want to achieve is:

  1. When the cursor reach the top border of lower div, instead of moving cursor into the top div, can we scroll the content to show the lines above?
  2. The scroll bar has to apply to the whole page, just as what it is now.
about 4 years ago · Juan Pablo Isaza
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