WhoKnew Views™ | Custom CSS – Icon Styling

Skip to main content
Table of Contents
Print

Take complete control of icon appearance with custom colors, sizes, shadows, animations, and positioning beyond dropdown options

🎯 Overview: Icon Styling with Custom CSS

The icon is the visual anchor of your view counter—the eye symbol, chart icon, or custom graphic that draws attention. While the Styling tab offers dropdown controls for icon library, color, size, and shadows, Custom CSS unlocks unlimited icon customization:

  • 🎨 Custom colors beyond the color picker – Use rgba for transparency, gradients for multi-tone icons
  • 📏 Precise sizing for desktop and mobile – Set exact pixel sizes independently
  • ✨ Advanced shadows with multiple layers – Create glow effects, depth, and neon aesthetics
  • 🌀 Custom animations beyond the 4 presets – Write keyframe animations for any transform or effect
  • 📍 Icon positioning relative to text – Fine-tune alignment, spacing, and order
  • 🎭 Per-product icon variations – Different icon styles for different products or categories
  • 👻 Hiding icons selectively – Remove icons on specific products while keeping text

This article covers every aspect of icon styling with Custom CSS, from basic color overrides to complex multi-layered animations. We’ll explore the two key icon selectors (.view-counter-icon and .view-counter-icon-wrapper) and show you exactly how to override every dropdown setting.

💡 Prerequisites: Read “Custom CSS – Getting Started” First

This article assumes you understand CSS selectors, the !important flag, per-product targeting with .postid-X, and how to access the Custom CSS box. If you’re new to Custom CSS, start with Custom CSS – Getting Started.


🧩 The Two Icon Selectors

Icon styling requires understanding the difference between the icon wrapper and the icon itself:

HTML Structure

<div class="view-counter-icon-wrapper">
    <i class="view-counter-icon ion-ios-eye"></i>
</div>
SelectorTargetsUse For
.view-counter-icon-wrapperThe container div that holds the iconShadows (via filter: drop-shadow()), size (width/height), alignment, wrapper animations
.view-counter-iconThe actual icon element (<i> tag)Color, font-size (icon size), transforms, icon animations

Key distinction: Icon shadows use filter: drop-shadow() on the wrapper, not on the icon itself. Icon animations (rotate, scale) target the icon. This separation allows independent control of wrapper vs. icon properties.


🎨 Icon Color: Beyond the Color Picker

Basic Color Override

The simplest icon customization is changing the color:

/* Override icon color to bright red */
.view-counter-icon {
    color: #ef4444 !important;
}

Transparent Icons with rgba

Use rgba() for semi-transparent icons (great for subtle counters):

/* Semi-transparent black icon (50% opacity) */
.view-counter-icon {
    color: rgba(0, 0, 0, 0.5) !important;
}
/* Semi-transparent white icon (70% opacity) */
.view-counter-icon {
    color: rgba(255, 255, 255, 0.7) !important;
}

Gradient Icons (Webkit Only)

For Chrome, Safari, and Edge, you can apply gradients to icons using -webkit-background-clip:

/* Gradient icon (purple to pink) */
.view-counter-icon {
    background: linear-gradient(135deg, #667eea 0%, #ecee8ce259@f2a20d01.com%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

Note: Gradient icons don’t work in Firefox (it will show the fallback color property). For cross-browser compatibility, set a fallback color:

/* Gradient with fallback for Firefox */
.view-counter-icon {
    color: #667eea !important; /* Fallback for Firefox */
    background: linear-gradient(135deg, #667eea 0%, #ecee8ce259@f2a20d01.com%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

Per-Product Icon Colors

/* Red icon for product ID 123 */
.postid-123 .view-counter-icon {
    color: #ef4444 !important;
}
/* Green icon for all products in "Sale" category */
.product_cat-sale .view-counter-icon {
    color: #10b981 !important;
}

📏 Icon Size: Desktop & Mobile Control

Icon size is controlled by font-size (since icons are font glyphs) and the wrapper’s width/height:

Desktop Icon Size

/* Enlarge icon to 20px on desktop */
.view-counter-icon {
    font-size: 20px !important;
}
.view-counter-icon-wrapper {
    width: 20px !important;
    height: 20px !important;
}

Why set both? The icon’s font-size controls the glyph size, while the wrapper’s width/height prevents clipping or overflow. They should match.

Mobile Icon Size

Use a media query to shrink icons on mobile:

/* 20px icon on desktop, 14px on mobile (768px breakpoint) */
.view-counter-icon {
    font-size: 20px !important;
}
.view-counter-icon-wrapper {
    width: 20px !important;
    height: 20px !important;
}
@media (max-width: 768px) {
    .view-counter-icon {
        font-size: 14px !important;
    }
    .view-counter-icon-wrapper {
        width: 14px !important;
        height: 14px !important;
    }
}

Per-Product Icon Sizes

/* Huge icon for premium product (ID 456) */
.postid-456 .view-counter-icon {
    font-size: 30px !important;
}
.postid-456 .view-counter-icon-wrapper {
    width: 30px !important;
    height: 30px !important;
}

✨ Icon Shadows: Creating Depth and Glow

Icon shadows use filter: drop-shadow() on the wrapper, not the icon itself. This creates a true shadow that follows the icon’s shape.

Basic Drop Shadow

/* Subtle black shadow (x=0, y=2px, blur=4px) */
.view-counter-icon-wrapper {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) !important;
}

Colored Glow Effect

/* Blue glow (x=0, y=0, blur=8px) */
.view-counter-icon-wrapper {
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.8)) !important;
}
/* Neon pink glow */
.view-counter-icon-wrapper {
    filter: drop-shadow(0 0 12px rgba(236, 72, 153, 1)) !important;
}

Multiple Layered Shadows

Stack multiple drop-shadow() calls for depth:

/* Layered shadow: close shadow + outer glow */
.view-counter-icon-wrapper {
    filter: 
        drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2))
        drop-shadow(0 0 12px rgba(59, 130, 246, 0.6)) !important;
}

Animated Shadow (Pulsing Glow)

/* Pulsing blue glow */
.view-counter-icon-wrapper {
    animation: icon-glow-pulse 2s ease-in-out infinite !important;
}
@keyframes icon-glow-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 16px rgba(59, 130, 246, 1));
    }
}

🌀 Icon Animations: Beyond the 4 Presets

The Styling tab offers 4 icon animations (Scale, Rotate, Pulse, Spin). Custom CSS lets you create any animation with @keyframes.

Understanding the Built-In Animations

Here’s how the plugin’s dropdown animations work (you can override or extend these):

AnimationKeyframesEffect
Scale0%: scale(1) → 100%: scale(1.5)Icon grows 50% larger
Rotate0%: rotate(0deg) → 100%: rotate(360deg)Icon spins 360° flat rotation
Pulse0%: scale(1) → 50%: scale(1.2) → 100%: scale(1)Icon pulses in/out (heartbeat effect)
Spin0%: rotateY(0deg) → 100%: rotateY(360deg)Icon flips 3D (requires perspective)

Custom Animation: Bounce

/* Bouncing icon */
.view-counter-icon {
    animation: icon-bounce 1s ease-in-out infinite !important;
}
@keyframes icon-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

Custom Animation: Swing

/* Swinging pendulum effect */
.view-counter-icon {
    animation: icon-swing 2s ease-in-out infinite !important;
    transform-origin: top center;
}
@keyframes icon-swing {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(15deg);
    }
    75% {
        transform: rotate(-15deg);
    }
}

Custom Animation: Shake

/* Shaking icon (attention-grabber) */
.view-counter-icon {
    animation: icon-shake 0.5s ease-in-out infinite !important;
}
@keyframes icon-shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-3px);
    }
    75% {
        transform: translateX(3px);
    }
}

Hover-Triggered Animation

Play animation only when hovering over the counter:

/* No animation by default */
.view-counter-icon {
    animation: none !important;
}
/* Rotate on hover */
.product-views-counter:hover .view-counter-icon {
    animation: icon-rotate 1s linear infinite !important;
}
@keyframes icon-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

On-Scroll Animation (Intersection Observer)

The plugin adds a .visible class when the counter scrolls into view. Use this for entrance animations:

/* No animation initially */
.view-counter-icon {
    animation: none !important;
    opacity: 0;
}
/* Fade in and scale when scrolled into view */
.view-counter-icon.visible {
    animation: icon-entrance 1s ease forwards !important;
}
@keyframes icon-entrance {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

⚠️ Animation Performance Tip

Stick to animating transform and opacity for smooth 60fps animations. Avoid animating width, height, top, left, or color (these cause repaints and lag). Use transform: scale() instead of width, transform: translate() instead of top/left.


📍 Icon Positioning Relative to Text

By default, the icon appears before the text (left side). You can change this with Flexbox or absolute positioning.

Move Icon After Text (Right Side)

/* Icon appears after text */
.view-counter-wrapper {
    flex-direction: row-reverse !important;
}

Move Icon Above or Below Text

/* Icon above text (vertical stack) */
.view-counter-wrapper {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
}
/* Icon below text */
.view-counter-wrapper {
    flex-direction: column-reverse !important;
    align-items: center !important;
    text-align: center !important;
}

Adjust Gap Between Icon and Text

/* Increase gap to 15px */
.view-counter-wrapper {
    gap: 15px !important;
}
/* Remove gap entirely (icon touching text) */
.view-counter-wrapper {
    gap: 0 !important;
}

Vertically Align Icon with Text

If the icon doesn’t align perfectly with text baseline:

/* Move icon down 2px for better alignment */
.view-counter-icon-wrapper {
    margin-top: 2px !important;
}
/* Or use transform (doesn't affect layout) */
.view-counter-icon {
    transform: translateY(2px) !important;
}

👻 Hiding Icons Selectively

Hide Icon Globally (Show Text Only)

/* Hide icon everywhere */
.view-counter-icon-wrapper {
    display: none !important;
}

Hide Icon on Specific Products

/* Hide icon only on product ID 789 */
.postid-789 .view-counter-icon-wrapper {
    display: none !important;
}

Hide Icon on Mobile Only

/* Show icon on desktop, hide on mobile */
@media (max-width: 768px) {
    .view-counter-icon-wrapper {
        display: none !important;
    }
}

🎨 Real-World Icon Styling Examples

Example 1: Premium Product Icon (Bold Red with Glow)

/* Apply to product ID 456 */
.postid-456 .view-counter-icon {
    color: #ef4444 !important;
    font-size: 22px !important;
}
.postid-456 .view-counter-icon-wrapper {
    width: 22px !important;
    height: 22px !important;
    filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.8)) !important;
    animation: icon-pulse-glow 2s ease-in-out infinite !important;
}
@keyframes icon-pulse-glow {
    0%, 100% {
        filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.8));
    }
    50% {
        filter: drop-shadow(0 0 20px rgba(239, 68, 68, 1));
    }
}

Example 2: Subtle Minimalist Icon (Gray, Small, No Shadow)

/* Apply globally */
.view-counter-icon {
    color: rgba(107, 114, 128, 0.6) !important; /* Gray, 60% opacity */
    font-size: 10px !important;
}
.view-counter-icon-wrapper {
    width: 10px !important;
    height: 10px !important;
    filter: none !important; /* Remove shadow */
}

Example 3: Animated Spinning Icon (On Hover)

/* No animation by default */
.view-counter-icon {
    transition: transform 0.3s ease !important;
}
/* Spin continuously on hover */
.product-views-counter:hover .view-counter-icon {
    animation: icon-spin 1s linear infinite !important;
}
@keyframes icon-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

Example 4: Neon Glow Icon (Cyberpunk Aesthetic)

/* Bright cyan icon with layered neon glow */
.view-counter-icon {
    color: #06b6d4 !important;
    font-size: 18px !important;
}
.view-counter-icon-wrapper {
    width: 18px !important;
    height: 18px !important;
    filter: 
        drop-shadow(0 0 4px rgba(6, 182, 212, 1))
        drop-shadow(0 0 8px rgba(6, 182, 212, 0.8))
        drop-shadow(0 0 16px rgba(6, 182, 212, 0.5)) !important;
}

Example 5: Category-Based Icon Colors

/* Blue icons for Electronics category */
.product_cat-electronics .view-counter-icon {
    color: #3b82f6 !important;
}
/* Pink icons for Clothing category */
.product_cat-clothing .view-counter-icon {
    color: #ec4899 !important;
}
/* Green icons for Home & Garden category */
.product_cat-home-garden .view-counter-icon {
    color: #10b981 !important;
}

🔍 Troubleshooting Icon Styles

Issue 1: Icon Color Not Changing

Cause: Missing !important or wrong selector.

Solution:

/* ✅ CORRECT: Targets icon, uses !important */
.view-counter-icon {
    color: #ef4444 !important;
}
/* ❌ WRONG: Targets wrapper, not icon */
.view-counter-icon-wrapper {
    color: #ef4444 !important; /* Won't work */
}

Issue 2: Icon Shadow Not Applying

Cause: Using box-shadow instead of filter: drop-shadow(), or targeting icon instead of wrapper.

Solution:

/* ✅ CORRECT: filter on wrapper */
.view-counter-icon-wrapper {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) !important;
}
/* ❌ WRONG: box-shadow doesn't work on font icons */
.view-counter-icon {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important; /* Won't work */
}

Issue 3: Icon Animation Not Looping

Cause: Missing animation-iteration-count: infinite.

Solution:

/* ✅ CORRECT: Infinite loop */
.view-counter-icon {
    animation: icon-spin 2s linear infinite !important;
}
/* ❌ WRONG: Plays once, stops */
.view-counter-icon {
    animation: icon-spin 2s linear !important; /* Missing 'infinite' */
}

Issue 4: Icon Size Doesn’t Match on Mobile

Cause: Plugin’s media query overriding your CSS.

Solution: Use !important in your media query:

@media (max-width: 768px) {
    .view-counter-icon {
        font-size: 16px !important; /* !important beats plugin */
    }
    .view-counter-icon-wrapper {
        width: 16px !important;
        height: 16px !important;
    }
}

✅ Quick Reference: Icon Styling Essentials

PropertySelectorExample
Icon Color.view-counter-iconcolor: #ef4444 !important;
Icon Size.view-counter-iconfont-size: 20px !important;
Wrapper Size.view-counter-icon-wrapperwidth: 20px !important; height: 20px !important;
Icon Shadow.view-counter-icon-wrapperfilter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)) !important;
Icon Animation.view-counter-iconanimation: icon-spin 2s linear infinite !important;
Icon Position.view-counter-wrapperflex-direction: row-reverse !important;
Icon-Text Gap.view-counter-wrappergap: 15px !important;
Hide Icon.view-counter-icon-wrapperdisplay: none !important;

Share