The root cause involves all three areas you mentioned: CSS structure conflicts, improper HTML nesting, and violation of Zoho’s UI guidelines for custom widgets.
First, restructure your HTML with proper nesting hierarchy. The current flat structure with direct span siblings is incompatible with Zoho CRM’s widget rendering engine:
<div class="loyalty-widget-container">
<div class="loyalty-content-wrapper">
<div class="badge-group">
<div class="points-badge">1,250 pts</div>
<div class="tier-badge">Gold</div>
</div>
</div>
</div>
Using divs instead of spans provides better layout control, and the nested container structure isolates your widget from Zoho’s default styles. The outer container establishes widget boundaries, the content wrapper handles responsive behavior, and the badge-group manages badge positioning.
Second, implement CSS that follows Zoho’s widget UI guidelines and prevents style conflicts:
.loyalty-widget-container {
width: 100%;
box-sizing: border-box;
padding: 12px;
}
.badge-group {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.points-badge, .tier-badge {
display: inline-flex;
padding: 6px 12px;
border-radius: 4px;
}
The key is using flexbox with flex-wrap for responsive behavior rather than fighting Zoho’s default positioning. The gap property handles spacing without margin conflicts, and inline-flex on badges prevents the overlap issue you’re experiencing.
Third, address responsive breakpoints using Zoho’s widget viewport handling. Custom media queries often fail because Zoho widgets render in an iframe with different viewport dimensions. Instead, use percentage-based widths and flexbox wrapping:
For mobile compatibility, the flex-wrap: wrap in badge-group allows badges to stack naturally on smaller screens without explicit breakpoints. Add max-width constraints if needed:
.badge-group {
max-width: 100%;
justify-content: flex-start;
}
Critical implementation notes:
- Load your CSS in the widget configuration’s “Style” section, not as an external file
- Use class selectors with at least two levels of specificity (.loyalty-widget-container .badge-group) to override Zoho defaults
- Avoid !important declarations - they cause maintenance issues and conflict with Zoho’s theme system
- Test in the actual CRM environment, not in external HTML files - Zoho injects wrapper elements that affect rendering
The CSS structure should follow Zoho’s box model (border-box sizing), the HTML nesting must provide isolation layers, and the responsive approach should rely on flexible layouts rather than fixed breakpoints. This three-part solution addresses the overlap bug, responsive collapse issue, and style conflicts comprehensively.