Skip to content

Instantly share code, notes, and snippets.

@fanvyr
Created December 16, 2018 16:15
Show Gist options
  • Save fanvyr/402a62d2a704d5830e8bc2a88895d6d2 to your computer and use it in GitHub Desktop.
Save fanvyr/402a62d2a704d5830e8bc2a88895d6d2 to your computer and use it in GitHub Desktop.
iFrame responsive positioning
<template>
<div class="aspect-ratio">
<iframe
class="video"
:src="'https://www.youtube-nocookie.com/embed/' + data.videoUrl "
frameborder="0"
allow="autoplay; encrypted-media"
allowfullscreen
></iframe>
</div>
</template>
<style scoped>
.aspect-ratio {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56%; /* The height of the item will now be 56% of the width. */
}
.aspect-ratio iframe {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment