Craft Device-Perfect Counters: Mobile Breakpoints, Touch Optimization & Adaptive Design
WhoKnew Views™ includes powerful mobile responsiveness controls—breakpoint configuration, mobile-specific font sizes, position overrides, and visibility toggles. But Custom CSS unlocks unlimited adaptive possibilities: device-specific animations, touch-optimized interactions, orientation-based layouts, high-DPI adjustments, and precise control over how your counters appear across the entire spectrum of devices.
💡 What This Guide Covers
The plugin’s built-in mobile controls handle width, font size, icon size, position overrides, and show/hide logic based on a configurable breakpoint. This article explores custom media queries, orientation targeting, device-specific optimizations, touch interactions, performance-conscious mobile animations, progressive enhancement, and accessibility considerations for creating counters that shine on every screen size.
🎯 Understanding WhoKnew Views™ Mobile System
Before diving into Custom CSS, let’s understand what WhoKnew Views™ already does:
| Built-In Feature | What It Controls | Breakpoint |
|---|---|---|
| Breakpoint (px) | Global trigger point for all mobile styles | Default: 768px |
| Width (Small Screens, %) | Counter width below breakpoint | Adjustable per product |
| Font Size (Small Screens, px) | Text size below breakpoint | Independent from desktop |
| Icon Size (Small Screens, px) | Icon dimensions below breakpoint | Scales independently |
| Mobile Position Overrides | Top, left, right, bottom mobile values | Optional per-product |
| Mobile Visibility | Show on Both / Desktop Only / Mobile Only | Simple show/hide toggle |
The plugin uses this CSS pattern:
@media (max-width: 768px) {
.product-views-counter {
width: 50%; /* Example: Width (Small Screens) */
font-size: 14px; /* Example: Font Size (Small Screens) */
}
.view-counter-icon-wrapper {
width: 18px; /* Example: Icon Size (Small Screens) */
height: 18px;
}
}
Custom CSS lets you extend, override, or create entirely new responsive behaviors beyond this foundation.
📐 Media Query Fundamentals
Media queries are the backbone of responsive design. They apply CSS rules based on device characteristics.
Basic Media Query Syntax
@media (condition) {
/* CSS rules here */
}
Common Media Query Conditions
| Query Type | Syntax | Targets |
|---|---|---|
max-width | @media (max-width: 768px) | Screens up to 768px wide |
min-width | @media (min-width: 769px) | Screens 769px and wider |
orientation | @media (orientation: portrait) | Vertical orientation (height > width) |
orientation | @media (orientation: landscape) | Horizontal orientation (width > height) |
hover | @media (hover: none) | Touch devices (no hover capability) |
hover | @media (hover: hover) | Devices with hover (mouse/trackpad) |
pointer | @media (pointer: coarse) | Touch input (fingers, stylus) |
pointer | @media (pointer: fine) | Precise input (mouse, trackpad) |
resolution | @media (min-resolution: 2dppx) | High-DPI displays (Retina, etc.) |
Combining Multiple Conditions
Use and to require multiple conditions, or commas to create “or” logic:
/* Mobile devices in portrait orientation */
@media (max-width: 768px) and (orientation: portrait) {
.product-views-counter .view-counter-wrapper {
flex-direction: column !important;
text-align: center !important;
}
}
/* Tablets OR landscape phones */
@media (min-width: 481px) and (max-width: 1024px),
(max-width: 768px) and (orientation: landscape) {
.product-views-counter {
font-size: 16px !important;
}
}
📏 Custom Breakpoint Strategies
WhoKnew Views™ uses one global breakpoint (default 768px). Custom CSS lets you create multiple breakpoints for precise device targeting.
Multi-Tier Responsive System
/* Small phones (up to 480px) */
@media (max-width: 480px) {
.product-views-counter {
font-size: 12px !important;
}
.view-counter-icon-wrapper {
width: 16px !important;
height: 16px !important;
}
}
/* Large phones / small tablets (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
.product-views-counter {
font-size: 14px !important;
}
.view-counter-icon-wrapper {
width: 18px !important;
height: 18px !important;
}
}
/* Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
.product-views-counter {
font-size: 16px !important;
}
.view-counter-icon-wrapper {
width: 22px !important;
height: 22px !important;
}
}
/* Desktop (1025px and up) - default styling applies */
Result: Four distinct size tiers ensure your counter is perfectly proportioned on every device—from tiny phones to large tablets.
⚡ Mobile-First vs Desktop-First
Mobile-first: Write base styles for mobile, then use min-width queries to enhance for larger screens. Desktop-first: Write base styles for desktop, then use max-width queries to simplify for mobile. WhoKnew Views™ uses desktop-first (base styles assume desktop, media query for mobile). Custom CSS can layer either approach on top.
🔄 Orientation-Based Layouts
Device orientation dramatically changes available space. Optimize counter placement and layout for portrait vs landscape.
Example: Compact Portrait, Expanded Landscape
/* Portrait: Stack icon above text to save horizontal space */
@media (max-width: 768px) and (orientation: portrait) {
.product-views-counter .view-counter-wrapper {
flex-direction: column !important;
align-items: center !important;
gap: 4px !important;
}
.product-views-counter {
width: 90% !important;
bottom: 20px !important;
left: 5% !important;
}
}
/* Landscape: Horizontal layout with more breathing room */
@media (max-width: 768px) and (orientation: landscape) {
.product-views-counter .view-counter-wrapper {
flex-direction: row !important;
gap: 8px !important;
}
.product-views-counter {
width: 40% !important;
bottom: 15px !important;
left: 10px !important;
}
}
Result: In portrait (tall screens), the counter stacks vertically and spans most of the width. In landscape (wide screens), it sits compactly in the corner with horizontal layout. Responds to device rotation in real-time.
🖐️ Touch-Optimized Interactions
Touch devices lack hover states and require larger tap targets. Optimize for finger-friendly interactions.
Disable Hover Effects on Touch Devices
/* Desktop: Hover effects enabled */
@media (hover: hover) and (pointer: fine) {
.product-views-counter .view-counter-wrapper:hover {
transform: translateY(-4px) !important;
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2) !important;
}
}
/* Touch devices: No hover, larger tap target */
@media (hover: none) and (pointer: coarse) {
.product-views-counter .view-counter-wrapper {
padding: 12px 24px !important; /* Bigger tap area */
}
}
Result: Mouse users get sophisticated hover effects; touch users get a slightly larger, more tappable counter with no hover behavior (which would never trigger anyway).
Touch-Activated Animation
Since touch devices can’t hover, use :active for press feedback:
@media (hover: none) and (pointer: coarse) {
.product-views-counter .view-counter-wrapper:active {
transform: scale(0.95) !important;
transition: transform 0.1s ease !important;
}
}
Result: When a user taps and holds the counter on a touch device, it briefly shrinks—providing tactile feedback that the touch was registered.
⚡ Performance-Conscious Mobile Animations
Mobile devices have less processing power and smaller batteries. Simplify or disable animations on mobile for smooth performance.
Example: Disable Complex Animations on Mobile
/* Desktop: Complex 3D rotation */
@media (min-width: 769px) {
@keyframes complex3D {
0% { transform: perspective(800px) rotateY(0deg) rotateX(0deg); }
100% { transform: perspective(800px) rotateY(360deg) rotateX(360deg); }
}
.product-views-counter .view-counter-wrapper {
animation: complex3D 3s ease-in-out !important;
}
}
/* Mobile: Simple fade-in */
@media (max-width: 768px) {
@keyframes simpleFade {
from { opacity: 0; }
to { opacity: 1; }
}
.product-views-counter .view-counter-wrapper {
animation: simpleFade 0.5s ease-out !important;
}
}
Result: Desktop users see a cinematic 3D rotation; mobile users see a lightweight fade—both appropriate for their device’s capabilities.
Reduce Motion for Accessibility
Some users enable “Reduce Motion” in their OS settings due to vestibular disorders. Respect this preference:
@media (prefers-reduced-motion: reduce) {
.product-views-counter .view-counter-wrapper {
animation: none !important;
transition: none !important;
}
}
Result: Users with motion sensitivity see no animations—counters appear instantly. This is a critical accessibility consideration.
♿ Accessibility Best Practice
Always include @media (prefers-reduced-motion: reduce) when using animations. This media query detects if the user has enabled “Reduce Motion” in their system preferences and allows you to provide a static alternative. It’s not just good practice—it’s essential for users with motion disorders.
🖼️ High-DPI & Retina Display Optimization
High-resolution displays (Retina, 4K, etc.) can make text and icons look sharper—or expose low-quality assets.
Example: Crisper Shadows on Retina Displays
/* Standard displays */
.product-views-counter .view-counter-text {
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
}
/* High-DPI displays: Sharper, more refined shadow */
@media (min-resolution: 2dppx) {
.product-views-counter .view-counter-text {
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) !important;
}
}
Result: On Retina displays, the text shadow is tighter and darker—taking advantage of higher pixel density for a crisper appearance.
📍 Advanced Mobile Positioning
The plugin’s mobile position overrides handle top/left/right/bottom. Custom CSS adds safe-area insets for notched devices and dynamic positioning based on viewport units.
Example: Safe Area Insets (iPhone Notch Support)
@media (max-width: 768px) {
.product-views-counter {
/* Ensure counter doesn't hide behind iPhone notch/home indicator */
top: max(10px, env(safe-area-inset-top)) !important;
bottom: max(10px, env(safe-area-inset-bottom)) !important;
left: max(10px, env(safe-area-inset-left)) !important;
right: max(10px, env(safe-area-inset-right)) !important;
}
}
Result: On notched devices (iPhone X and later), the counter automatically adjusts position to avoid the notch, curved corners, and home indicator. On standard devices, it uses the 10px fallback.
Example: Viewport Units for Dynamic Sizing
@media (max-width: 768px) {
.product-views-counter {
/* Width scales with viewport width */
width: 80vw !important; /* 80% of viewport width */
max-width: 300px !important; /* Cap at 300px */
}
.product-views-counter .view-counter-text {
/* Font size scales with viewport width */
font-size: 3.5vw !important; /* 3.5% of viewport width */
min-font-size: 12px !important; /* Floor at 12px */
max-font-size: 16px !important; /* Cap at 16px */
}
}
Result: Counter width and text size scale proportionally to the screen size, with min/max caps preventing extremes. Creates a fluid, truly responsive experience.
🎨 Conditional Styling Based on Device Context
Combine multiple media queries to create context-aware styling.
Example: Different Styles for Phone, Tablet, Desktop
/* Phones: Minimal, compact */
@media (max-width: 480px) {
.product-views-counter .view-counter-wrapper {
background: transparent !important;
border: none !important;
box-shadow: none !important;
padding: 4px 8px !important;
}
}
/* Tablets: Subtle border, light background */
@media (min-width: 481px) and (max-width: 1024px) {
.product-views-counter .view-counter-wrapper {
background: rgba(255, 255, 255, 0.8) !important;
border: 1px solid rgba(0, 0, 0, 0.1) !important;
border-radius: 8px !important;
padding: 8px 16px !important;
}
}
/* Desktop: Full gradient, shadow, effects */
@media (min-width: 1025px) {
.product-views-counter .view-counter-wrapper {
background: linear-gradient(135deg, #667eea, #764ba2) !important;
border-radius: 12px !important;
box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4) !important;
padding: 12px 24px !important;
}
}
Result: Phones see a stripped-down counter (no background, no effects). Tablets see a lightly styled counter (subtle background). Desktops see the full-featured counter (gradient, shadow, padding). Progressive enhancement based on device capability.
🔍 Container Queries (Modern Approach)
Container queries let elements respond to their parent container’s size rather than the viewport—perfect for responsive components.
⚠️ Browser Support Note
Container queries are a newer CSS feature (2023+). Supported in Chrome 105+, Safari 16+, Firefox 110+. Not supported in Internet Explorer or older browsers. Provide fallbacks for critical styling.
Example: Counter Adapts to Container Width
/* Define container */
.woocommerce-product-gallery {
container-type: inline-size !important;
container-name: product-gallery !important;
}
/* When gallery is narrow (<500px), stack counter vertically */
@container product-gallery (max-width: 500px) {
.product-views-counter .view-counter-wrapper {
flex-direction: column !important;
font-size: 12px !important;
}
}
/* When gallery is wide (>500px), use horizontal layout */
@container product-gallery (min-width: 501px) {
.product-views-counter .view-counter-wrapper {
flex-direction: row !important;
font-size: 16px !important;
}
}
Result: The counter responds to the product gallery’s width, not the viewport. If the gallery is narrow (even on a wide desktop), the counter adjusts—perfect for complex layouts, sidebars, and grid systems.
🚀 Real-World Mobile Examples
Example 1: Mobile E-commerce Optimized Counter
/* Small phones: Minimal, bottom-center */
@media (max-width: 480px) {
.product-views-counter {
position: fixed !important; /* Fixed to viewport */
bottom: max(10px, env(safe-area-inset-bottom)) !important;
left: 50% !important;
transform: translateX(-50%) !important;
width: 90% !important;
font-size: 13px !important;
}
.product-views-counter .view-counter-wrapper {
background: rgba(0, 0, 0, 0.85) !important;
color: #ffffff !important;
padding: 8px 16px !important;
border-radius: 20px !important;
backdrop-filter: blur(10px) !important;
}
/* Disable complex animations */
.product-views-counter * {
animation: none !important;
}
}
Use Case: Mobile shoppers. Counter is fixed to the bottom of the viewport (always visible while scrolling), centered, with a dark frosted-glass background for maximum legibility over product images. Animations disabled for performance.
Example 2: Tablet Landscape Optimization
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
.product-views-counter {
top: 20px !important;
right: 20px !important;
left: auto !important;
bottom: auto !important;
width: auto !important;
}
.product-views-counter .view-counter-wrapper {
padding: 10px 20px !important;
background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(139, 92, 246, 0.9)) !important;
border-radius: 10px !important;
}
}
Use Case: Tablets in landscape mode. Counter positioned in top-right corner with semi-transparent gradient—takes advantage of the wider screen without blocking product image.
Example 3: Progressive Enhancement for High-End Mobiles
/* Budget phones: Ultra-lightweight */
@media (max-width: 768px) {
.product-views-counter .view-counter-wrapper {
animation: fadeIn 0.3s ease-out !important;
}
}
/* High-end phones with hover support (rare but exists) */
@media (max-width: 768px) and (hover: hover) and (min-resolution: 2dppx) {
.product-views-counter .view-counter-wrapper {
animation: zoomFadeIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
transition: transform 0.3s ease !important;
}
.product-views-counter .view-counter-wrapper:hover {
transform: scale(1.05) !important;
}
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes zoomFadeIn {
0% { opacity: 0; transform: scale(0.8); }
100% { opacity: 1; transform: scale(1); }
}
Result: Budget/standard phones get a simple fade-in. High-end phones with advanced capabilities (Retina display + hover support) get a bouncy zoom entrance and hover scaling—progressive enhancement in action.
⚠️ Troubleshooting
| Issue | Solution |
|---|---|
| Media query not applying | Ensure !important is used to override plugin defaults. Check selector specificity: .product-views-counter .view-counter-wrapper is required. |
| Breakpoint conflicts with plugin | Plugin uses max-width: 768px by default (configurable). Your custom queries should avoid exact overlap. Use 767px or 769px boundaries, or use different query types (orientation, hover). |
| Orientation query not triggering | Device must physically rotate for orientation queries to re-evaluate. Test by rotating device or resizing browser window to trigger aspect ratio change. |
| Hover query doesn’t detect touch | @media (hover: none) targets primary input. Some devices (Surface Pro) have both touch and mouse, so may report hover: hover. Combine with pointer: coarse for more reliable touch detection. |
| Safe area insets not working | Requires <meta name="viewport" content="viewport-fit=cover"> in site’s <head>. Most modern themes include this, but older themes may not. |
| Container queries not applying | Check browser support (Chrome 105+, Safari 16+, Firefox 110+). Provide fallback with standard @media queries for older browsers. |
| Performance lag on mobile animations | Use transform and opacity only (GPU-accelerated). Avoid animating width, height, top, left. Consider disabling animations entirely on mobile: @media (max-width: 768px) { * { animation: none !important; } } |
📚 Quick Reference: Essential Media Queries
| Media Query | Targets | Use Case |
|---|---|---|
(max-width: 480px) | Small phones | Ultra-compact styling |
(max-width: 768px) | Phones & small tablets | General mobile styling (matches plugin default) |
(min-width: 769px) and (max-width: 1024px) | Tablets | Intermediate sizing |
(orientation: portrait) | Vertical orientation | Tall, narrow layouts |
(orientation: landscape) | Horizontal orientation | Wide, short layouts |
(hover: none) | Touch devices | Disable hover effects |
(pointer: coarse) | Touch input | Larger tap targets |
(min-resolution: 2dppx) | Retina/high-DPI | Sharper graphics |
(prefers-reduced-motion: reduce) | Motion-sensitive users | Disable animations (accessibility) |
(prefers-color-scheme: dark) | Dark mode users | Dark theme styling |