WhoKnew Views™ | Z-Index & Layer Management

Skip to main content
Table of Contents
Print

Control Stacking Order and Ensure Your Counter Appears Above (or Below) All Page Elements

🎯 Overview: The Third Dimension of Positioning

You’ve mastered where your counter appears (coordinates) and how wide it is (width). Now it’s time to control the third dimension: depth. Z-Index determines the stacking order of overlapping elements—which ones appear on top and which ones hide behind others.

Think of z-index as layers in Photoshop or Pages—elements with higher z-index values float above elements with lower values. Without proper z-index management, your counter might be hidden behind product images, badges, sale ribbons, or other theme elements.

⚡ Quick Win: The default Medium (100) z-index works for 95% of stores. But if your counter disappears behind product images, sale badges, or sticky headers, change Z-Index to High (1000)—problem solved instantly. For Fixed positioning (sticky counters), always use High.


📚 Understanding Z-Index: The Stacking Order System

Z-index is a CSS property that controls the vertical stacking order of positioned elements (absolute, relative, or fixed). Elements are layered like a deck of cards—higher z-index values are “on top,” lower values are “underneath.”

🔢 The Z-Index Scale

Z-index values are integers (whole numbers) with no theoretical limit. Common ranges:

Z-Index RangeTypical UseExamples
0-9Base layer elementsBackground images, base containers
10-99Low-priority overlaysDecorative elements, subtle badges
100-999Standard UI elementsTooltips, dropdowns, most counters
1000-9999High-priority UISticky headers, modals, fixed elements
10000+Top-layer elementsCritical alerts, full-screen modals
Negative valuesBehind-the-scenes elementsWatermarks, background overlays

🎨 Visual Stacking Example

Z-Index Stacking (Side View):
┌─────────────────────┐ ← z-index: 1000 (Top layer - Counter)
  ┌─────────────────┐   ← z-index: 500 (Middle - Sale Badge)
    ┌─────────────┐     ← z-index: 1 (Bottom - Product Image)
    │ Product Img │
    └─────────────┘
  └─────────────────┘
└─────────────────────┘
Higher z-index = Closer to viewer

🎛️ The Two Z-Index Controls

WhoKnew Views provides two settings for z-index management:

📍 Setting 1: Z-Index (Preset Dropdown)

A dropdown with four preset values that cover most scenarios:

OptionZ-Index ValueWhen to Use
Low (10)10Counter sits below most elements (subtle, non-intrusive)
Medium (100) ⭐100Default, works for standard Absolute positioning
High (1000)1000Counter floats above almost everything (for Fixed positioning)
CustomYour valueActivates the Custom Z-Index field for manual entry

🔢 Setting 2: Custom Z-Index (Number Field)

When you select Custom in the dropdown, this field activates, allowing you to enter any integer value:

  • Positive values d43a9342@bd340d6d.com): Place counter above elements
  • Zero (0): Default browser stacking (no explicit z-index)
  • Negative values (-1 to -999999): Place counter behind elements

💡 Pro Tip: For 99% of users, the preset dropdown (Low/Medium/High) is sufficient. Only use Custom Z-Index if you’re troubleshooting specific theme conflicts or need the counter to integrate with complex layering (e.g., matching your theme’s sticky header at z-index: 9999).


🔍 When to Use Each Z-Index Preset

📉 Low (10): Subtle, Understated Counters

✅ Use When:
  • Counter should be subtle and not dominate the product image
  • You want other elements (sale badges, “NEW” ribbons) to appear above the counter
  • Product images have busy backgrounds and you don’t want the counter to clash
  • Minimalist aesthetic where the counter is secondary to product visuals
❌ Avoid When:
  • Using Fixed positioning (sticky counters need high z-index)
  • Counter is being hidden behind product images or theme elements
  • Social proof is a primary conversion driver (low z-index reduces visibility)
Common Theme Conflicts:

Low z-index (10) can be hidden behind:

  • Product images with z-index: 50
  • WooCommerce gallery overlays (z-index: 100)
  • Hover effects and zoom features

📊 Medium (100): The Universal Default

✅ Use When:
  • Absolute positioning with standard product overlays (default scenario)
  • Theme uses typical z-index conventions (most WooCommerce themes do)
  • Counter should float above product images but below modals/headers
  • No specific layering issues observed
✅ Why It’s the Default:

Z-index 100 strikes the perfect balance:

  • Above product images (typically z-index: 1-50)
  • Above most badges/ribbons (typically z-index: 10-80)
  • Below sticky headers (typically z-index: 1000+)
  • Below modals/popups (typically z-index: 9999+)
⚙️ Theme Compatibility:

Medium (100) works with 95% of WooCommerce themes because most themes follow this hierarchy:

  • Base content: z-index: 1-10
  • Product elements: z-index: 50-99
  • Your counter: 100 ✅
  • Theme overlays: z-index: 500-999
  • Global UI: z-index: 1000+

📈 High (1000): Maximum Visibility

✅ Use When:
  • Fixed positioning (sticky counters) → Always use High for Fixed mode
  • Counter is hidden behind theme elements even at Medium (100)
  • Theme uses high z-index values for product galleries (some premium themes do)
  • Counter must stay visible above everything except critical modals
  • Overlapping with sticky “Add to Cart” buttons or floating action bars
🎯 Fixed Positioning Requirement:

If your Position is set to Fixed, you must use High (1000) or higher. Here’s why:

  • Fixed elements float above the page, potentially overlapping headers, navigation, and content
  • Most themes use z-index: 1000+ for sticky headers
  • Without high z-index, your fixed counter disappears behind the header when users scroll

⚠️ Critical Rule:Fixed positioning + Medium z-index = Hidden counter. If you use Fixed mode, always pair it with High (1000) or Custom (9999+). This is non-negotiable for visibility.

❌ When NOT to Use High:
  • Absolute positioning with no conflicts (Medium works fine—no need for overkill)
  • You want modals, popups, or cookie notices to appear above the counter
  • Theme’s sticky elements should take priority over the counter

🔧 Custom: Surgical Z-Index Control

✅ Use When:
  • Presets (10/100/1000) don’t solve your specific layering issue
  • You need to match your theme’s exact z-index hierarchy (e.g., theme uses z-index: 850 for badges)
  • Want the counter behind product images (negative values like -1)
  • Building complex layered designs with multiple overlapping elements
  • Theme developer provided a specific z-index value for compatibility
📋 Custom Value Examples:
Custom ValueEffectUse Case
-1Counter behind product imageWatermark-style background counter
50Mid-layer (between presets)Above image, below badges
500High mid-layerAbove most UI, below sticky elements
9999Top layer (almost everything)Critical social proof, always visible
99999Absolute top layerAbove modals (use sparingly!)

💡 Developer Tip: Inspect your theme’s elements with browser DevTools (F12 → Elements → Computed Styles → z-index) to see exact z-index values. Then set your counter’s Custom Z-Index to theme_value + 1 to float just above it.


🔗 How Z-Index Interacts with Positioning Modes

Z-index only works on positioned elements (absolute, relative, or fixed). The positioning mode affects how z-index behaves:

📐 Z-Index + Absolute Positioning

  • Counter stacks relative to product gallery container
  • Medium (100) usually sufficient
  • Competes with product images, badges, zoom overlays
  • Recommendation: Start with Medium, increase to High if conflicts occur

📄 Z-Index + Relative Positioning

  • Counter stays in document flow but can be layered
  • Z-index less critical (fewer overlapping elements)
  • Low (10) or Medium (100) typically fine
  • Recommendation: Use Medium unless counter is purely decorative (then Low)

📌 Z-Index + Fixed Positioning

  • Counter floats above entire viewport, overlapping all page content
  • High (1000) is mandatory to stay above headers, navigation, and content
  • Competes with sticky headers, mobile menus, modals, cookie notices
  • Recommendation: Use High (1000) minimum; Custom (9999) for critical visibility
Position ModeRecommended Z-IndexWhy
AbsoluteMedium (100)Above product images, standard layering
RelativeLow (10) or Medium (100)In document flow, fewer conflicts
FixedHigh (1000) or Custom (9999)Floating above viewport, must beat headers

🛠️ Troubleshooting Z-Index & Layering Issues

Issue 1: “My counter is hidden behind the product image”

Root Cause

Product image has higher z-index than the counter, or theme CSS is overriding counter’s z-index.

✅ Solution
  1. Increase Z-Index from Medium (100) to High (1000)
  2. If still hidden, use Custom and try 9999
  3. Check if theme CSS has z-index: 9999 !important on product images (rare but possible)
  4. If theme override exists, use Custom CSS to force counter: .product-views-counter { z-index: 99999 !important; }

Issue 2: “Counter disappears when I scroll (Fixed positioning)”

Root Cause

You’re using Fixed positioning with Low (10) or Medium (100) z-index. Theme’s sticky header (z-index: 1000+) is covering it.

✅ Solution
  • Change Z-Index to High (1000)
  • If header is z-index: 1000 exactly, use Custom 1001 or 9999
  • Test by scrolling—counter should stay visible above header

Issue 3: “Counter is blocking modal popups or cookie notices”

Root Cause

Counter’s z-index is too high, floating above critical UI elements that should be on top.

✅ Solution
  • Reduce Z-Index from High (1000) to Medium (100)
  • Modals typically use z-index: 9999-99999, so 100 keeps counter below them
  • If using Fixed positioning and modals are still blocked, use Custom 999 (below 1000 modal threshold)

Issue 4: “Sale badge or ‘NEW’ ribbon is hidden behind counter”

Root Cause

Counter’s z-index is higher than badge’s z-index.

✅ Solution
  • Reduce Counter Z-Index to Low (10) so badges (typically z-index: 50-100) float above it
  • Or use Custom Z-Index 49 to ensure badges at z-index: 50+ appear on top

Issue 5: “Counter appears above everything, even admin bars”

Root Cause

Using Custom Z-Index with excessively high value (99999+).

✅ Solution
  • Reduce to High (1000) or Custom 9999
  • WordPress admin bars use z-index: 99999, so anything below that respects admin UI
  • Only exceed 99999 if you have a specific reason

Issue 6: “Want counter to look like a watermark (behind image)”

Solution
  • Select Custom in Z-Index dropdown
  • Enter -1 in Custom Z-Index field
  • Counter will render behind the product image
  • Increase Opacity to 0.3-0.5 for subtle watermark effect

📚 Technical Deep Dive: Stacking Contexts

🧱 Understanding Stacking Contexts

Z-index doesn’t work in isolation—it operates within stacking contexts. A stacking context is a three-dimensional conceptualization of HTML elements along an imaginary z-axis.

Key Concept:

Elements within the same stacking context are compared by z-index. Elements in different contexts are isolated—child elements can’t “escape” their parent’s layer.

Example:
<div style="z-index: 1; position: relative;"> ← Parent Context
    <div style="z-index: 9999;"> ← Child (still in parent's layer)
        Counter (can't escape parent's z-index: 1)
    </div>
</div>
<div style="z-index: 2;"> ← Different Context
    This will appear ABOVE the z-index: 9999 counter
    because it's in a parent with z-index: 2 (higher than 1)
</div>
WhoKnew Views Implementation:

Your counter is rendered inside the product gallery container, which creates its stacking context. If the gallery has z-index: 50, your counter can’t float above an element with z-index: 100 outside the gallery.

🔍 Why This Matters: If you set Z-Index to 9999 and the counter is still hidden, it’s likely a stacking context issue. The product gallery container may have a low z-index. Solution: Use Fixed positioning (which creates its own stacking context relative to viewport) or ask your theme developer to adjust gallery z-index.

🎨 CSS Output Examples

Medium (100) – Default:
.product-views-counter {
    position: absolute;
    z-index: 100;
    /* ...other styles... */
}
High (1000) – Fixed Positioning:
.product-views-counter {
    position: fixed;
    z-index: 1000;
    /* ...other styles... */
}
Custom (9999) – Manual Override:
.product-views-counter {
    position: absolute;
    z-index: 9999; /* Your custom value */
    /* ...other styles... */
}
Custom (-1) – Background Watermark:
.product-views-counter {
    position: absolute;
    z-index: -1; /* Behind product image */
    opacity: 0.4; /* Semi-transparent watermark */
    /* ...other styles... */
}

🎓 Best Practices & Recommendations

✅ Do’s

  • Start with Medium (100) for Absolute positioning—it’s the default for good reason
  • Always use High (1000) for Fixed positioning (sticky counters)
  • Test with live preview after changing z-index to ensure visibility
  • Use browser DevTools (F12) to inspect theme element z-index values if troubleshooting
  • Increment z-index conservatively—try Medium first, then High, then Custom if needed
  • Document Custom values in Custom CSS comments (e.g., /* z-index: 9999 to beat theme header (z-index: 9998) */)

❌ Don’ts

  • Don’t use Custom with extreme values (999999) unless absolutely necessary—causes maintenance issues
  • Don’t use Fixed + Medium—counter will be hidden behind headers when scrolling
  • Don’t forget to test modals—ensure counter doesn’t block popups/cookie notices
  • Don’t assume higher is always better—Low (10) is perfect for subtle counters
  • Don’t use negative z-index for Absolute counters unless you want them behind the product image (watermark effect)

🎯 Golden Rule: Use the lowest z-index that achieves visibility. Don’t set z-index to 99999 “just in case”—use Medium (100) unless you have a specific conflict, then increment to High (1000), then Custom if needed. Minimal z-index values prevent future conflicts and improve theme compatibility.

Share