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

333
Visualizações
CSS header's height remain constant after calc()
--dis: calc(var(--max-height) - var(--min-height));
/*
  @media large{--min-height:13rem};
  @media small{--min-height:6.5rem};
  --max-height:75vh;
*/

--percent: calc(var(--scroll-ani) / var(--dis));
/* 
  in js: document.body.style = "--scroll-ani:" + document.scrollingElement.scrollTop; 
  This code will correctly output the distance between the top of the visual area and the top of the page
*/

--percent-limited: calc((var(--percent) - 1 - abs(var(--percent) - 1)) / 2 + 1);
/*
  If percent > 1, percent-limited = 1,
  If percent < 1, percent-limited = percent,
  Percent cannot be less than 0.
*/
obj{
  position: fixed;/* header itself will not cause the page height to change*/
  width:100vw;
  height: calc(var(--max-height) - var(--dis) * var(--percent-limited));
}

But height remains unchanged.

--percent-limited work like this: Graph of y=(x-1-abs(x-1))/2+1 It's graph of y=(x-1-abs(x-1))/2+1

x will never be less than 0, so range of y will be [0,1]

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

0

The CSS calc() function only allows multiplication when at least one side is unitless.

The multiplication here is not currently possible with CSS:

height: calc(var(--max-height) - var(--dis) * var(--percent-limited));

CSS tricks article on calc()

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