Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
Ocultar un elemento html si una var css es mayor que algún valor

Me gustaría ocultar un elemento si un css var es mayor que cero. Puedo hacer que funcione el caso inverso:

 #container { display: flex; width: 100%; height: 30px; border: 1px soild black; } .item { opacity: max(calc( var(--ind)*1), 0); /* or clamp(var(--ind), 0 , 1);*/ width: 30px; height: 100%; }
 <div id="container"> <div class="item" style="--ind: 0;background-color:red;"></div> <div class="item" style="--ind: 1;background-color:orange;"></div> <div class="item" style="--ind: 2;background-color:yellow;"></div> <div class="item" style="--ind: 3;background-color:green;"></div> <div class="item" style="--ind: 4;background-color:blue;"></div> </div>

Sin embargo, me gustaría que el ejemplo anterior muestre solo el cuadrado rojo. ¿Alguien puede ver cómo hacer esto (en CSS puro)?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

 #container { display: flex; width: 100%; height: 30px; border: 1px soild black; } .item { opacity: min(calc( 1 - var(--ind)), 1); width: 30px; height: 100%; }
 <div id="container"> <div class="item" style="--ind: 0;background-color:red;"></div> <div class="item" style="--ind: 1;background-color:orange;"></div> <div class="item" style="--ind: 2;background-color:yellow;"></div> <div class="item" style="--ind: 3;background-color:green;"></div> <div class="item" style="--ind: 4;background-color:blue;"></div> </div>

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!