You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在计数器模块各区域下方添加Font Awesome图标?

Fixing Font Awesome Icon Placement for Your Counter Sections

Hey there! I get it—having that Font Awesome icon stuck next to the counter number looks totally messy. Let's rearrange things so the icon sits neatly below each counter's description instead. Here's how to do it step by step:

1. Restructure Your HTML for Better Control

Instead of shoving everything into a single div, split the counter number, description, and icon into separate elements. This makes styling way easier:

<div class="sqs-col sqs-col-3 counter-value" data-count="300" data-desc="Donations">
  <span class="counter-number">0</span>
  <span class="counter-desc">Donations</span>
  <i class="fab fa-500px"></i>
</div>

We’re using <span>s for the number and description, then placing the icon directly below them inside the same container.

2. Add CSS to Align Everything Vertically

Use flexbox to make the counter container stack its content top-to-bottom, centered horizontally. Add this to your stylesheet:

.counter-value {
  display: flex;
  flex-direction: column;
  align-items: center; /* Centers all content horizontally */
  text-align: center;
  padding: 1rem; /* Optional: Add breathing room around the counter */
}

.counter-number {
  font-size: 2.5rem; /* Adjust size to match your design */
  font-weight: 700;
}

.counter-desc {
  margin: 0.75rem 0; /* Adds space between number and description */
  font-size: 1rem;
}

.counter-value i {
  font-size: 1.75rem; /* Resize the icon as needed */
  color: #2c3e50; /* Customize the icon color to fit your theme */
}

This will ensure the icon sits cleanly below the description, not cramped next to the number.

3. Update Your Counter Script to Target the Right Element

If your existing script was updating the entire counter-value div's text, it would overwrite your description and icon. We need to adjust it to only update the counter-number span:

var a = 0;
$(window).scroll(function() {
  var oTop = $('.counter-value').offset().top - window.innerHeight;
  if (a == 0 && $(window).scrollTop() > oTop) {
    $('.counter-value').each(function() {
      var $this = $(this),
          countTo = $this.attr('data-count');
      
      $({ countNum: $this.find('.counter-number').text() }).animate({
        countNum: countTo
      }, {
        duration: 2000,
        easing: 'swing',
        step: function() {
          // Only update the number span, not the whole div
          $this.find('.counter-number').text(Math.floor(this.countNum));
        },
        complete: function() {
          $this.find('.counter-number').text(this.countNum);
        }
      });
    });
    a = 1;
  }
});

The key change here is using $this.find('.counter-number') instead of targeting the entire counter-value div when updating the text.

Why This Works

Your original setup had all content (number, description, icon) as inline elements inside the div, so the browser rendered them side-by-side. By splitting into separate elements and using flexbox, we force vertical stacking, giving you the clean, organized layout you want.

内容的提问来源于stack exchange,提问作者J. Zar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:25:43