Skip to content

Instantly share code, notes, and snippets.

@fwalzel
Created December 7, 2023 14:02
Show Gist options
  • Select an option

  • Save fwalzel/3a2a77feba570dc3732f92a0d86b7ed0 to your computer and use it in GitHub Desktop.

Select an option

Save fwalzel/3a2a77feba570dc3732f92a0d86b7ed0 to your computer and use it in GitHub Desktop.
Embed scaling Html5 Video with constrained proportions, autoplaying
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Embed scaling Video, constraied proportions</title>
</head>
<body>
<div style="width: 100%; position: relative;">
<div style="padding-bottom: calc(100% * 720 / 1280); position: relative;">
<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: transparent;">
<video id="videocontainer" style="padding: 0; margin: 0; width: 100%; height: 100%; display: block;" autoplay muted playsinline>
<source src="https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
Your browser does not support the video.
</video>
</div>
</div>
</div>
<script>
document.getElementById('videocontainer').play();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment