Responsive iframe containers for videos, maps, and embedded content
| Class | Purpose | Default Aspect Ratio |
|---|---|---|
.rsl-iframe-container |
Responsive iframe wrapper | 16:9 (56.25% padding-bottom) |
| Ratio | Padding-Bottom | Use Case |
|---|---|---|
| 16:9 | 56.25% | YouTube videos, modern widescreen (default) |
| 4:3 | 75% | Classic presentations, older videos |
| 1:1 | 100% | Square content, Instagram-style |
| 21:9 | 42.86% | Ultrawide, cinematic content |
| 3:2 | 66.67% | Photography, some presentations |
| Attribute | Purpose | Required? |
|---|---|---|
src |
URL of embedded content | Yes |
title |
Accessible description for screen readers | Yes (accessibility) |
allowfullscreen |
Enables fullscreen mode for videos | Recommended for videos |
loading |
lazy = load when near viewport | Optional (performance) |
allow |
Feature permissions (autoplay, camera, etc.) | Optional |
The simplest responsive iframe uses the default 16:9 aspect ratio.
Override the default with inline padding-bottom style.
Include permissions for YouTube features.
Embed maps with lazy loading for performance.
Skip the container for fixed-height iframes.
position: relative and width: 100%padding-bottom: 56.25% creates height based on width (16:9 ratio)position: absolute and fills the container
.rsl-iframe-container {
position: relative;
width: 100%;
padding-bottom: 56.25%; /* 16:9 aspect ratio */
overflow: hidden;
}
.rsl-iframe-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
.rsl-iframe-container for the positioning to work correctly.
Combine video with description and call-to-action
Getting Started Tutorial
Watch this 5-minute video to learn the basics.
Show text alongside embedded preview
Features
- Zero dependencies
- ADA compliant
- Grid-powered
Embed Google Maps with contact information
Visit Us
Address:
123 Main St, City, State
Phone:
(555) 123-4567
Multiple embedded examples side-by-side
Example 1
Example 2
Example 3
Always provide a descriptive title attribute for screen readers.
Use loading="lazy" for iframes below the fold.
prefers-reduced-motion may be sensitive to automatic animations. Consider using a static thumbnail with a play button instead of autoplay.
Iframe containers work seamlessly with all RSL grid features.
Video caption
/embed/ URL format, not the regular watch URL
padding-bottom = (height / width) × 100%
border: 0 to remove default iframe borders for cleaner appearance
.rsl-iframe-container.rsl-iframe-container classsrc URL is correct and accessiblepadding-bottom percentage matches desired aspect ratiowidth: 100% (default in .rsl-iframe-container).rsl-iframe-container for fixed-height iframeswidth and height directly to iframe elementView iframes.html for realistic use cases
Use playground.html as a starting point
Learn about RSL Grid System for responsive layouts