Skip to content

Instantly share code, notes, and snippets.

@YoshiTheChinchilla
Created November 27, 2020 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YoshiTheChinchilla/7940fa1933404aa9e94786d39f115d0b to your computer and use it in GitHub Desktop.
Save YoshiTheChinchilla/7940fa1933404aa9e94786d39f115d0b to your computer and use it in GitHub Desktop.
simple implementation in Vue.js of auto adjusting height for YouTube iFrame
<template>
<div class="iframe-container">
<iframe class="iframe-content" src="https://www.youtube.com/embed/g06zI68Blzk"></iframe>
</div>
</template>
<script>
export default {}
</script>
<style scoped>
.iframe-container {
width: 100%;
/* Aspect ratio of 16:9 */
padding-bottom: 56.25%;
height: 0px;
position: relative;
}
.iframe-content {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment