Set Different Counter Positions for Mobile Devices and Master Responsive Design
You’ve mastered desktop positioning with Top/Bottom/Left/Right coordinates, responsive width with the Breakpoint system, and layering with Z-Index. Now it’s time for the ultimate responsive control: Mobile Position Overrides—the ability to set completely different coordinates for mobile devices.
Mobile screens are fundamentally different from desktop: they’re smaller, portrait-oriented, and users interact with them differently. A counter positioned perfectly at top: 0px; left: 0px; on desktop might obstruct the product title or “Add to Cart” button on mobile. Mobile Position Overrides solve this by letting you define mobile-specific Top/Bottom/Left/Right values that activate below the breakpoint.
⚡ Quick Win: Enable Mobile Position Override, and the plugin automatically copies your desktop coordinates to mobile fields as a starting point. Adjust the mobile values while watching the live preview (resize your browser to test), then save. Your counter now adapts perfectly to both desktop and mobile—no CSS coding required.
📱 What Are Mobile Position Overrides?
Mobile Position Overrides are a responsive positioning system that creates two sets of coordinates:
| Screen Size | Coordinates Used | When They Apply |
|---|---|---|
| Desktop (above breakpoint) | Top, Bottom, Left, Right (standard fields) | Screen width ≥ Breakpoint (e.g., 1024px+) |
| Mobile (below breakpoint) | Mobile Top, Mobile Bottom, Mobile Left, Mobile Right | Screen width < Breakpoint (e.g., below 1024px) |
🔧 Three Requirements for Mobile Overrides
Mobile Position Override fields only appear when all three conditions are met:
- Position is set to Absolute or Fixed (not Relative)
- Mobile Visibility is set to Show on Both (not Desktop Only or Mobile Only)
- Mobile Position Override checkbox is enabled
💡 Why These Requirements? Relative positioning doesn’t use coordinates, so overrides don’t apply. If Mobile Visibility is “Desktop Only,” the counter doesn’t appear on mobile at all. These are logical safeguards to prevent confusion.
🎛️ The Mobile Override Controls
☑️ Control 1: Mobile Position Override (Checkbox)
This checkbox activates the mobile positioning system. When checked, four new fields appear:
- Mobile Top Position
- Mobile Bottom Position
- Mobile Left Position
- Mobile Right Position
✅ When to Enable Mobile Override
| Scenario | Enable Override? | Reason |
|---|---|---|
| Counter blocks mobile buttons | ✅ Yes | Reposition to avoid obstructing UI elements |
| Counter looks cramped on small screens | ✅ Yes | Move to less cluttered area (e.g., top-center) |
| Desktop position works fine on mobile | ❌ No | No need—desktop coordinates already work universally |
| Fixed positioning (sticky counter) | ✅ Yes (often) | Sticky counters may need different viewport placement on mobile |
| Portrait vs landscape differences | ✅ Yes | Portrait mobile screens benefit from centered or bottom placement |
⚠️ Common Mistake: Don’t enable Mobile Override “just in case.” If your desktop coordinates work well on mobile (test by resizing your browser), leave it disabled. Extra complexity = more maintenance. Only override when you have a specific mobile positioning need.
📍 Controls 2-5: Mobile Position Fields
These four fields mirror the desktop Top/Bottom/Left/Right controls, but only apply below the breakpoint:
| Field | Controls | Accepts |
|---|---|---|
| Mobile Top Position | Distance from top edge (mobile) | Number + Unit (px or %) |
| Mobile Bottom Position | Distance from bottom edge (mobile) | Number + Unit (px or %) |
| Mobile Left Position | Distance from left edge (mobile) | Number + Unit (px or %) |
| Mobile Right Position | Distance from right edge (mobile) | Number + Unit (px or %) |
🔄 Auto-Populate Feature
When you first enable Mobile Position Override, the plugin automatically copies your desktop coordinates to the mobile fields. This gives you a starting point—you then adjust only the values that need to change for mobile.
Example:
Desktop Coordinates:
- Top: 0px
- Left: 0px
- Bottom: auto
- Right: auto
✅ Enable Mobile Override → Auto-populates:
- Mobile Top: 0px (copied from desktop)
- Mobile Left: 0px (copied from desktop)
- Mobile Bottom: auto (copied from desktop)
- Mobile Right: auto (copied from desktop)
You then adjust, e.g.:
- Mobile Top: 10px (add padding on mobile)
- Mobile Left: 50% (center horizontally on mobile)🔄 Control 6: Reset Mobile Positions Button
A button that appears when Mobile Override is enabled. Clicking it copies all desktop coordinates back to mobile fields, letting you start over if mobile positioning goes wrong.
✅ When to Use Reset Button
- Mobile coordinates are completely wrong and you want to start fresh
- You changed desktop coordinates and want to re-sync mobile to match
- Testing: quickly revert mobile to desktop values to compare
🔬 How Mobile Overrides Work Behind the Scenes
📐 CSS Media Query Generation
When Mobile Override is enabled, the plugin generates two sets of CSS:
Desktop CSS (Default):
.product-views-counter {
position: absolute;
top: 0px; /* Desktop Top */
left: 0px; /* Desktop Left */
bottom: auto; /* Desktop Bottom */
right: auto; /* Desktop Right */
/* ...other styles... */
}Mobile CSS (Below Breakpoint):
@media (max-width: 1024px) {
.product-views-counter {
top: 10px !important; /* Mobile Top (overrides desktop) */
left: 50% !important; /* Mobile Left (overrides desktop) */
bottom: auto !important; /* Mobile Bottom */
right: auto !important; /* Mobile Right */
transform: translateX(-50%) !important; /* Auto-centering for 50% */
}
}🎯 The !important Flag
Mobile overrides use !important to ensure they always override desktop coordinates below the breakpoint. Without it, CSS cascade rules might cause desktop values to persist on mobile.
🔀 Override Logic Flow
User loads page → Browser checks screen width
Is screen width < Breakpoint (1024px)?
↓ NO (Desktop)
└─→ Apply Desktop Coordinates (top: 0px; left: 0px)
↓ YES (Mobile)
└─→ Is Mobile Override enabled?
↓ NO
└─→ Apply Desktop Coordinates (same as desktop)
↓ YES
└─→ Apply Mobile Coordinates (top: 10px; left: 50%)💡 Pro Tip: If Mobile Override is disabled, mobile devices simply use the desktop coordinates. The breakpoint still affects Width and Font Size, but positioning stays the same. This is why mobile overrides are optional—they’re only needed when desktop positioning doesn’t work on mobile.
🛠️ Common Mobile Override Recipes
Recipe 1: Desktop Top-Left → Mobile Centered Top
Problem: Top-left counter looks awkward on narrow mobile screens.
| Screen | Top | Left | Bottom | Right |
|---|---|---|---|---|
| Desktop | 0px | 0px | auto | auto |
| Mobile | 10px | 50% | auto | auto |
Result: Desktop: top-left corner. Mobile: top-center with 10px padding (auto-transform centers it).
Recipe 2: Desktop Top-Left → Mobile Bottom-Right
Problem: Counter blocks product title or “Add to Cart” button on mobile.
| Screen | Top | Left | Bottom | Right |
|---|---|---|---|---|
| Desktop | 0px | 0px | auto | auto |
| Mobile | auto | auto | 15px | 15px |
Result: Desktop: top-left. Mobile: bottom-right with 15px inset (out of the way).
Recipe 3: Fixed Sticky → Different Mobile Viewport Position
Problem: Sticky counter in top-right on desktop overlaps mobile menu icon.
| Screen | Position Mode | Top | Left | Bottom | Right |
|---|---|---|---|---|---|
| Desktop | Fixed | 20px | auto | auto | 20px |
| Mobile | Fixed | auto | 20px | 20px | auto |
Result: Desktop: top-right corner of viewport (sticky). Mobile: bottom-left corner of viewport (avoids mobile header).
Recipe 4: Desktop 15px Inset → Mobile More Padding
Problem: 15px padding looks tight on mobile; need more breathing room.
| Screen | Top | Left | Bottom | Right |
|---|---|---|---|---|
| Desktop | 15px | 15px | auto | auto |
| Mobile | 25px | 25px | auto | auto |
Result: Same position (top-left), but mobile has 10px extra padding on top/left edges.
Recipe 5: Keep Desktop Coordinates (No Override Needed)
Scenario: Desktop top: 0px; left: 0px; works perfectly on mobile—no obstruction, looks good.
| Setting | Value |
|---|---|
| Mobile Position Override | ❌ Disabled |
| Desktop Coordinates | top: 0px; left: 0px; |
| Mobile Coordinates | (Uses desktop—override not needed) |
Result: Same position on all devices. Simplest solution when it works!
🔗 How Mobile Overrides Interact with Other Settings
📏 Breakpoint
The Breakpoint setting determines when mobile coordinates activate:
- Breakpoint: 1024px → Screens 1024px or narrower use mobile coordinates
- Breakpoint: 768px → Screens 768px or narrower use mobile coordinates (tablets still use desktop)
- Breakpoint: 1440px → Screens 1440px or narrower use mobile coordinates (even small laptops get mobile positioning)
Your breakpoint choice affects how many devices see the mobile coordinates. Lower breakpoint = fewer devices. Higher breakpoint = more devices.
📐 Width (Small Screens)
Mobile overrides control position, while Width Small controls size. They work together:
| Below Breakpoint, Plugin Applies | Setting | Example Value |
|---|---|---|
| Mobile Position (if override enabled) | Mobile Top/Left/etc. | top: 10px; left: 50%; |
| Width Small | Width (Small Screens) | 100% |
| Font Size Small | Font Size (Small Screens) | 12px |
| Icon Size Small | Icon Size (Small) | 12px |
📱 Mobile Visibility
Mobile Visibility affects whether the counter appears on mobile. Mobile Overrides affect where it appears:
| Mobile Visibility | Mobile Override | Result |
|---|---|---|
| Show on Both | Enabled | ✅ Counter visible on mobile, uses mobile coordinates |
| Show on Both | Disabled | ✅ Counter visible on mobile, uses desktop coordinates |
| Desktop Only | (N/A) | ❌ Counter hidden on mobile (override checkbox hidden) |
| Mobile Only | (N/A) | ✅ Counter only on mobile, but override checkbox hidden (no desktop to override!) |
🔍 Why Override Checkbox Hides: If Mobile Visibility is “Desktop Only,” the counter doesn’t appear on mobile, so mobile positioning is irrelevant. If “Mobile Only,” there are no desktop coordinates to override—the counter only exists on mobile, so it just uses the standard Top/Bottom/Left/Right fields.
🛠️ Troubleshooting Mobile Override Issues
Issue 1: “Mobile override checkbox isn’t showing”
Root Cause
One of the three requirements isn’t met.
✅ Solution Checklist
- Is Position set to Absolute or Fixed? (Not Relative)
- Is Mobile Visibility set to Show on Both? (Not Desktop/Mobile Only)
- Are you looking in the right section? (It’s in the “Position Settings” section, below the standard position fields)
Issue 2: “I enabled override, but mobile position fields aren’t showing”
Root Cause
JavaScript hasn’t toggled field visibility yet, or Position is Relative.
✅ Solution
- Scroll to the Mobile Position Override checkbox and uncheck, then re-check it to trigger field visibility
- Refresh the page (sometimes fields don’t show until page reload)
- Verify Position is Absolute or Fixed (not Relative)
Issue 3: “Mobile coordinates aren’t applying (counter still uses desktop position)”
Root Cause
Screen width is above the breakpoint, or mobile override checkbox isn’t checked.
✅ Solution
- Check Breakpoint setting (default: 1024px). If testing on a 1280px screen, mobile coords won’t apply yet—resize browser narrower or use DevTools (F12 → Toggle Device Toolbar → iPhone)
- Ensure Mobile Position Override checkbox is checked and you clicked Save
- Clear browser cache (mobile CSS may be cached)
Issue 4: “Reset button does nothing”
Root Cause
Desktop coordinates are empty or invalid.
✅ Solution
- Ensure desktop Top/Bottom/Left/Right fields have valid values (not all empty)
- Click Reset button, then immediately click Save to persist the reset
- Check browser console (F12 → Console) for JavaScript errors
Issue 5: “Mobile position looks wrong after breakpoint change”
Root Cause
You changed the Breakpoint, but mobile coordinates were optimized for the old breakpoint.
✅ Solution
- Re-test mobile position at the new breakpoint (e.g., if you changed from 1024px to 768px, tablets now use desktop coordinates—may need adjustment)
- Use Reset button to re-sync mobile to desktop, then re-adjust mobile coords for new breakpoint
📚 Technical Deep Dive: Auto-Populate Logic
🔄 When Auto-Populate Triggers
The auto-populate feature runs in two scenarios:
- First-time enable: When you check Mobile Override and mobile fields are empty, desktop values copy instantly (JavaScript in admin)
- On save: When saving with override enabled and mobile fields empty, desktop values merge into mobile fields (PHP backend)
🧠 Smart Empty Detection
The plugin treats these as “empty” (triggers auto-populate):
- Field value is
''(empty string) - Field value is
null(not set in database)
But '0' (zero) is not empty—it’s a valid coordinate! This ensures:
top: 0px;doesn’t get overwritten by desktop value- You can intentionally set mobile coordinates to zero
📝 Backend Sanitization
The PHP sanitization function (whoknew_views_sanitize_styling_settings) includes auto-populate logic:
if ($sanitized['mobile_position_override'] == 1) {
$mobile_field_map = [
'mobile_top_position' => 'top_position',
'mobile_bottom_position' => 'bottom_position',
'mobile_left_position' => 'left_position',
'mobile_right_position' => 'right_position'
];
foreach ($mobile_field_map as $mobile_field => $desktop_field) {
// If mobile field is empty, copy from desktop
if ($mobile_value === '' || $mobile_value === null) {
$input[$mobile_field] = $input[$desktop_field];
}
}
}This ensures that even if JavaScript fails (rare), the backend catches it on save.
🎓 Best Practices & Recommendations
✅ Do’s
- Test on real devices after enabling mobile overrides—browser resize is good, but actual phones reveal more
- Start by enabling override and using auto-populated values, then adjust incrementally
- Use percentage centering (
left: 50%) for mobile if counter looks awkward at edges on small screens - Increase padding on mobile (e.g., desktop
10px, mobile20px) to avoid tight spacing on small screens - Use Reset button when desktop coordinates change—quickly re-sync mobile to match, then re-adjust
- Document your reasoning in Custom CSS comments if mobile positioning is complex
❌ Don’ts
- Don’t enable override “just in case”—only when desktop positioning doesn’t work on mobile
- Don’t forget to test at the breakpoint (e.g., 1024px exactly)—ensure smooth transition between desktop/mobile coords
- Don’t use wildly different coordinates on mobile unless necessary—consistency aids user experience
- Don’t set all four mobile coordinates (top+bottom, left+right) simultaneously—use top OR bottom, left OR right (set others to
auto) - Don’t forget Width Small—mobile position + width work together for full responsive control
🎯 Golden Rule:Test, test, test. Mobile overrides are powerful but require real-world testing. Use browser DevTools (F12 → Device Toolbar) to simulate iPhone, iPad, and Android sizes. If the counter looks good on desktop and mobile without overrides, skip them—simpler is better.