Created
December 16, 2018 16:15
-
-
Save fanvyr/402a62d2a704d5830e8bc2a88895d6d2 to your computer and use it in GitHub Desktop.
iFrame responsive positioning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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