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

311
Visualizações
Make a image re-visible by display: flex; after user scrolling a fixed height

I have an image (with myContent id) on my HTML page, for which I put display: None in my css.

my code:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
</head>
<body>

    <!-- header start -->
    <div class="container-fluid">
        <div class="jumbotron">
            <h1>Header area</h1>
        </div>
    </div>
    <!-- header end -->

    <!-- Your page contant start -->
    <div class="container-fluid">
        <div class="alert alert-primary" style="height: 800px;">
            <h1>Your page contant area</h1>
            <img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" id="myContent">
        </div>
    </div>
    <!-- Your page contant end -->

<style>
    #myContent{
        display: none;
    }
</style>

</body>
</html>

When any visitor scrolls down(approximately equal header height) and the header/ jumbotron section goes up(for scrolling), then I want to make the image re-visible by applying display: flex;

Please suggest how can I implement this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

best chance would be javascript, create an eventlisener on scroll, check users current scroll.y position and when higher then x add class else remove class, a class that add display:flex;

could look something like this

let img = document.querySelector('#myContent')
document.addEventListener('scroll', function(e) {
if(window.scrollY > heightofyourelement){
img.classList.add('show')
}else{
img.classList.remove('show')
}
})
about 4 years ago · Juan Pablo Isaza 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