Make video embed responsive
This commit is contained in:
parent
e34427ae1f
commit
6c5f36c46a
2 changed files with 14 additions and 4 deletions
|
@ -39,7 +39,9 @@ namespace Website.Markdig.Extensions {
|
|||
private bool RenderEmbed(HtmlRenderer renderer, LinkInline link) {
|
||||
if (YoutubeLink.IsMatch(link.Url)) {
|
||||
var youtubeMatch = YoutubeLink.Match(link.Url);
|
||||
renderer.Write(@"<div class=""video-container"">");
|
||||
renderer.Write($"<iframe src=\"https://www.youtube.com/embed/{youtubeMatch.Groups[1].Value}\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>");
|
||||
renderer.Write(@"</div>");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
iframe[src^="https://www.youtube.com/embed/"] {
|
||||
width: 944px;
|
||||
height: 531px;
|
||||
.video-container {
|
||||
position: relative;
|
||||
padding-bottom: 56.25%;
|
||||
|
||||
iframe {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue