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

210
Views
¿Puedo agregar una coma (,) dinámicamente a un pseudo elemento CSS cuyo valor proviene de la variable CSS?

Quiero insertar las comas apropiadamente entre los números. ej: 6,350

¿Hay alguna manera de que pueda lograr esto en el siguiente escenario?

 setTimeout(function () { $('.number-counter').each(function () { $(this).addClass('inView'); }); }, 500);
 @property --num { syntax: "<integer>"; initial-value: 0; inherits: false; } .number-counter { transition: --num 3s; counter-set: num var(--num); font: 800 40px system-ui; } .number-counter::after { content: counter(num); } .number-counter.inView { --num: var(--count); }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="number-counter" style="--count: 6350;"></div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intenté agregar este código en CSS pero no hay forma de contar los dígitos en CSS, así que agregué la coma (,) usando jQuery. Espero que esto ayude. Agregará la coma después de 3 dígitos.

 setTimeout(function () { jQuery('.number-counter').each(function () { jQuery(this).addClass('inView'); var $this = jQuery(this); countTo = $this.attr('data-count'); jQuery({ countNum: $this.text()}).animate({countNum: countTo}, { easing: 'linear', step: function() { $this.text(commaSeparateNumber(Math.ceil(this.countNum))); }, complete: function() { $this.text(commaSeparateNumber(Math.ceil(this.countNum))); } }); }); }, 500); function commaSeparateNumber(val) { while (/(\d+)(\d{3})/.test(val.toString())) { val = val.toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2'); } return val; }
 @property --num { syntax: "<integer>"; initial-value: 0; inherits: false; } .number-counter { transition: --num 3s; counter-set: num var(--num); font: 800 40px system-ui; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="number-counter" style="--count: 6350;" data-count="6350"></div>

about 4 years ago · Juan Pablo Isaza 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!