Height = 200% of the Width

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="&quot;Super Sleuths&quot;" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>

Have you tried using CSS to set the width and height?

For now, the Iframe automatically sets it, but I was trying all this in the browser before implementing this into the actual project.

You can set an intrinsic relationship between width and height using the padding method.

e.g.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
.iframeholder {
	width:60%;
	margin:auto;
	position:relative;
	padding:50% 0 0;/*the magic*/
}
.iframeholder iframe {
	width:100%;
	height:100%;
	position:absolute;
	left:0;
	top:0;
	right:0;
	bottom:0;
}
</style>
</head>

<body>
<div class="iframeholder">
  <iframe src="https://player.vimeo.com/video/113657402"  frameborder="0" title="&quot;Super Sleuths&quot;" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
</div>
</body>
</html>
3 Likes

Dimensions via the html attributes will only take pixels as units(without stating the units), you can’t have % there. To use % you must use css.

3 Likes

Html4 allowed pixels or percentages but I believe html5 changed to pixels only although I hazard to guess that percentages will work forever (although the same caveats for percentage height will still be evident.). (But of course css should be used anyway :slight_smile: )

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.