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

202
Visualizações
CSS Grid spacing increases on click

I am using a grid display for the body, and in one of my grid template containers, I have a nested grid template to organize my projects. however, whenever I click on a project and it expands it doubles the spacing between the body grid container elements causing the website to double in length.

body{
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
    grid-template-areas: 
    "text text text"
    ". picture ."
    "text text text "
    ". resume . "
    "text text text "
    "projects projects projects"
    "text  text text "
    ". text  ."
    ;
    

}

.projects{
    grid-area: projects;    
    align-items: center;
    display: grid;
    grid-template-columns: 2fr 2fr 2fr;
    grid-template-rows: 2fr 2fr 2fr;
    grid-template-areas:
    "project project project"
}   

Here is the Javascript Function to open the project

function openproject(){
    var text = document.getElementById("project") 
    var project = document.getElementById("project")
    var project2 = document.getElementById("project 2")
    if (text.style.display=="none"){
        text.style.display ="inline"
        project.style.backgroundColor = "hsl(49 37% 94%)"
        project.style.color ="var(--bg-color)"
        project2.style.display ="none" 
         
    }else{
        text.style.display ="none" 
        project.style.textDecoration="none"
        project.style.backgroundColor="var(--bg-color)"
        project.style.color="hsl(49 37% 94%)"
        project2.style.display ="inline" 
        
    }
}

and the HTML is essentially just variations of this

 <div class="projects">
        <div class="project" id="project" onclick="openproject()">
          Project Name! 
          <span id="projectText" class="projectText" style="display: none">
            <p>
              Text
            </p>
            <a
              href=link
              target="_blank"
              style="text-decoration: none; color: var(--bg-color)"
            >
              <strong> Check Out the Project! </strong>
            </a>
          </span>
        </div>

Thank You in advance!

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

0

This is the default value for the column-gap: column-gap: normal;

Grid column-gap gets a global value such as:

gap: inherit;
gap: initial;
gap: revert;
gap: unset;

It is good to declare it beforehand with values.

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