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

127
Visualizações
VAR setting in grid-template-columns assignment

In the following CSS, I can change the setting for:

    grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr)); 

by manually altering 25rem to 33rem or 40rem (or some other #rem)

I want to change the value using the CSS var setting, but am having a brain fark.

I have tried:

    .mainGrid {
      display: grid;
        grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr));   /* original version OK */
    /* none of the following work 
        grid-template-columns: repeat(auto-fit, minmax(var(--chars), 1fr));        --chars: '25rem';
        grid-template-columns: repeat(auto-fit, minmax(var(--chars)+'rem', 1fr));  --chars: 25;
    */
    }
    .mainGrid > section { border: 1px solid black; }

I can change the --chars value with JS, but neither changing 25 to 33 or '33rem' works

Is this just one area that the CSS var cannot be used because it is a count and not a string?

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

0

You have to do the following:

repeat(auto-fit, minmax(calc(var(--n,10)*1rem), 1fr)

The 10 is the default value if you don't specify any value for --n

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