Skip to content

Commit c69e3e8

Browse files
authored
Merge pull request #246 from ember-learn/embed-video
Helper for responsive video embeds
2 parents e8b6203 + 97228b3 commit c69e3e8

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

addon/styles/helpers.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,35 @@
339339
.rounded-lg {
340340
border-radius: var(--radius-lg);
341341
}
342+
343+
/**
344+
* Wrap YouTube and other iFrame based video embeds into this class.
345+
*
346+
* ```html
347+
* <div class="embed-video">
348+
* <!-- code from YouTube -->
349+
* <iframe
350+
* width="640"
351+
* height="360"
352+
* src="https://www.youtube.com/embed/rY5D38RQoEg"
353+
* frameborder="0"
354+
* allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
355+
* allowfullscreen
356+
* ></iframe>
357+
* <!-- /code from YouTube -->
358+
* </div>
359+
* ```
360+
*/
361+
.embed-video {
362+
position: relative;
363+
height: 0;
364+
padding: 0 0 56.25%; /* 16:9 */
365+
}
366+
367+
.embed-video > iframe {
368+
position: absolute;
369+
top: 0;
370+
left: 0;
371+
width: 100%;
372+
height: 100%;
373+
}

docs/css/helpers.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,20 @@ In order to apply the spacing scale on pages, a set of predefined helper classes
125125
{{/each}}
126126
</tbody>
127127
</table>
128+
129+
### Responsive Videos
130+
131+
```html
132+
<div class="embed-video">
133+
<!-- code from YouTube -->
134+
<iframe
135+
width="640"
136+
height="360"
137+
src="https://www.youtube.com/embed/rY5D38RQoEg"
138+
frameborder="0"
139+
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
140+
allowfullscreen
141+
></iframe>
142+
<!-- /code from YouTube -->
143+
</div>
144+
```

0 commit comments

Comments
 (0)