ratio() html()
A box that keeps an aspect ratio for an iframe, video or map.
html()->ratio($html = '', $extra = [])Options
| Option | Meaning |
|---|---|
$html | Developer HTML inside (an iframe, a video). |
ratio | 16x9 (default), 4x3, 1x1, 21x9 or any W x H (3:2 gets an inline style). |
class_add, id, style, data-*, attr | Attributes. |
Example
Code
return '<div style="max-width:320px">' . html()->ratio('<div class="embed-responsive-item" style="background:#6c757d;color:#fff;padding:1em">16x9</div>') . '</div>'
. '<div style="max-width:160px">' . html()->ratio('<div class="embed-responsive-item" style="background:#0d6efd;color:#fff;padding:1em">1x1</div>', ['ratio' => '1x1']) . '</div>';Bootstrap 3 and 5
Bootstrap 5 ratio ratio-16x9; Bootstrap 3 embed-responsive embed-responsive-16by9, which fills only an iframe, embed, object, video or .embed-responsive-item child.
See also: html/carousel