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>
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.
PaulOB
August 1, 2017, 11:07am
4
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=""Super Sleuths"" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
</div>
</body>
</html>
3 Likes
SamA74
August 1, 2017, 11:10am
5
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
PaulOB
August 1, 2017, 11:19am
6
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 )
3 Likes
system
Closed
October 31, 2017, 6:19pm
7
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.