Reputation: 727
suppose for a Media, which is a Vimeo Video the width is set to 100%, but If I set auto for height than the height comes out to be too low.
Later, I set a height of 500px for the Video/Media but is there a way so that I can set a height of 200% of the width.
<iframe src="https://player.vimeo.com/video/113657402" width="100%" height="500" frameborder="0" title=""Super Sleuths"" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
Upvotes: 0
Views: 44
Reputation: 42
You can use vw units for the width and height of the element. This allows to keep the element's aspect ratio according to the viewport width (Note : you can also see vh if you need to keep aspect ratio according to viewport height).
<iframe src="https://player.vimeo.com/video/113657402" width="10vw" height="20vw" frameborder="0" title=""Super Sleuths"" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
Upvotes: 1
Reputation: 13558
Try this, height: 56.25vw;
will maintain 16:9
Aspect Ratio
.wrapper {
position: relative;
height: 56.25vw;
width: 100%;
margin: 0 auto;
}
.wrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<div class="wrapper">
<iframe src="https://player.vimeo.com/video/113657402" width="100%" height="500" frameborder="0" title=""Super Sleuths"" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
</div>
Upvotes: 1