Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda