Video 100% width of parent element, auto height (16:9)












0














I would like both videos to be 100% width of their parent element while maintaining their aspect ratio.



The parent element is 50% of the window width, so the video has to be responsive.



I have found dozens of solutions - all virtually the same - that work for a video that is 100% width of the page as a background cover. However unfortunately this is not the solution for me.



To see the issue you'll probably need to open it in full page view.



Thanks, appreciate any help!






body {
margin: 0;
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 700;
src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 800;
src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 900;
src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: 400;
src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
}
.jan-container {
width: 100%;
font-family: "Roboto Condensed";
}
.jan-container .headline-athletes {
display: flex;
}
.jan-container .headline-athletes div {
position: relative;
width: 50%;
height: 900px;
background: red;
margin: 0 60px 0 0;
display: flex;
flex-direction: column;
}
.jan-container .headline-athletes div .videoWrapper {
width: 100% !important;
height: auto;
}
.jan-container .headline-athletes div .videoWrapper iframe {
width: 100% !important;
}
.jan-container .headline-athletes div:last-child {
margin: 0;
}

<section class="jan-container">

<div class="headline-athletes">
<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>

<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>

</section>












share|improve this question
























  • do you want to solve this with css only ?
    – Dirk
    Nov 23 '18 at 16:04










  • @Dirk Vanilla JS as well if that's an option, I should have clarified, will make an edit :)
    – GoldenGonaz
    Nov 23 '18 at 16:07
















0














I would like both videos to be 100% width of their parent element while maintaining their aspect ratio.



The parent element is 50% of the window width, so the video has to be responsive.



I have found dozens of solutions - all virtually the same - that work for a video that is 100% width of the page as a background cover. However unfortunately this is not the solution for me.



To see the issue you'll probably need to open it in full page view.



Thanks, appreciate any help!






body {
margin: 0;
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 700;
src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 800;
src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 900;
src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: 400;
src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
}
.jan-container {
width: 100%;
font-family: "Roboto Condensed";
}
.jan-container .headline-athletes {
display: flex;
}
.jan-container .headline-athletes div {
position: relative;
width: 50%;
height: 900px;
background: red;
margin: 0 60px 0 0;
display: flex;
flex-direction: column;
}
.jan-container .headline-athletes div .videoWrapper {
width: 100% !important;
height: auto;
}
.jan-container .headline-athletes div .videoWrapper iframe {
width: 100% !important;
}
.jan-container .headline-athletes div:last-child {
margin: 0;
}

<section class="jan-container">

<div class="headline-athletes">
<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>

<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>

</section>












share|improve this question
























  • do you want to solve this with css only ?
    – Dirk
    Nov 23 '18 at 16:04










  • @Dirk Vanilla JS as well if that's an option, I should have clarified, will make an edit :)
    – GoldenGonaz
    Nov 23 '18 at 16:07














0












0








0







I would like both videos to be 100% width of their parent element while maintaining their aspect ratio.



The parent element is 50% of the window width, so the video has to be responsive.



I have found dozens of solutions - all virtually the same - that work for a video that is 100% width of the page as a background cover. However unfortunately this is not the solution for me.



To see the issue you'll probably need to open it in full page view.



Thanks, appreciate any help!






body {
margin: 0;
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 700;
src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 800;
src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 900;
src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: 400;
src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
}
.jan-container {
width: 100%;
font-family: "Roboto Condensed";
}
.jan-container .headline-athletes {
display: flex;
}
.jan-container .headline-athletes div {
position: relative;
width: 50%;
height: 900px;
background: red;
margin: 0 60px 0 0;
display: flex;
flex-direction: column;
}
.jan-container .headline-athletes div .videoWrapper {
width: 100% !important;
height: auto;
}
.jan-container .headline-athletes div .videoWrapper iframe {
width: 100% !important;
}
.jan-container .headline-athletes div:last-child {
margin: 0;
}

<section class="jan-container">

<div class="headline-athletes">
<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>

<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>

</section>












share|improve this question















I would like both videos to be 100% width of their parent element while maintaining their aspect ratio.



The parent element is 50% of the window width, so the video has to be responsive.



I have found dozens of solutions - all virtually the same - that work for a video that is 100% width of the page as a background cover. However unfortunately this is not the solution for me.



To see the issue you'll probably need to open it in full page view.



Thanks, appreciate any help!






body {
margin: 0;
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 700;
src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 800;
src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 900;
src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: 400;
src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
}
.jan-container {
width: 100%;
font-family: "Roboto Condensed";
}
.jan-container .headline-athletes {
display: flex;
}
.jan-container .headline-athletes div {
position: relative;
width: 50%;
height: 900px;
background: red;
margin: 0 60px 0 0;
display: flex;
flex-direction: column;
}
.jan-container .headline-athletes div .videoWrapper {
width: 100% !important;
height: auto;
}
.jan-container .headline-athletes div .videoWrapper iframe {
width: 100% !important;
}
.jan-container .headline-athletes div:last-child {
margin: 0;
}

<section class="jan-container">

<div class="headline-athletes">
<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>

<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>

</section>








body {
margin: 0;
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 700;
src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 800;
src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 900;
src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: 400;
src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
}
.jan-container {
width: 100%;
font-family: "Roboto Condensed";
}
.jan-container .headline-athletes {
display: flex;
}
.jan-container .headline-athletes div {
position: relative;
width: 50%;
height: 900px;
background: red;
margin: 0 60px 0 0;
display: flex;
flex-direction: column;
}
.jan-container .headline-athletes div .videoWrapper {
width: 100% !important;
height: auto;
}
.jan-container .headline-athletes div .videoWrapper iframe {
width: 100% !important;
}
.jan-container .headline-athletes div:last-child {
margin: 0;
}

<section class="jan-container">

<div class="headline-athletes">
<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>

<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>

</section>





body {
margin: 0;
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 700;
src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 800;
src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 900;
src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: 400;
src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
}
.jan-container {
width: 100%;
font-family: "Roboto Condensed";
}
.jan-container .headline-athletes {
display: flex;
}
.jan-container .headline-athletes div {
position: relative;
width: 50%;
height: 900px;
background: red;
margin: 0 60px 0 0;
display: flex;
flex-direction: column;
}
.jan-container .headline-athletes div .videoWrapper {
width: 100% !important;
height: auto;
}
.jan-container .headline-athletes div .videoWrapper iframe {
width: 100% !important;
}
.jan-container .headline-athletes div:last-child {
margin: 0;
}

<section class="jan-container">

<div class="headline-athletes">
<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>

<div>
<div class="videoWrapper">
<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>

</section>






javascript html css video youtube






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 16:07

























asked Nov 23 '18 at 15:30









GoldenGonaz

430622




430622












  • do you want to solve this with css only ?
    – Dirk
    Nov 23 '18 at 16:04










  • @Dirk Vanilla JS as well if that's an option, I should have clarified, will make an edit :)
    – GoldenGonaz
    Nov 23 '18 at 16:07


















  • do you want to solve this with css only ?
    – Dirk
    Nov 23 '18 at 16:04










  • @Dirk Vanilla JS as well if that's an option, I should have clarified, will make an edit :)
    – GoldenGonaz
    Nov 23 '18 at 16:07
















do you want to solve this with css only ?
– Dirk
Nov 23 '18 at 16:04




do you want to solve this with css only ?
– Dirk
Nov 23 '18 at 16:04












@Dirk Vanilla JS as well if that's an option, I should have clarified, will make an edit :)
– GoldenGonaz
Nov 23 '18 at 16:07




@Dirk Vanilla JS as well if that's an option, I should have clarified, will make an edit :)
– GoldenGonaz
Nov 23 '18 at 16:07












1 Answer
1






active

oldest

votes


















1














i just remembered why i dont like iframes :)



this should work, you more or less just have to bind the same function to aresize event






var callback = function() {
var videos = document.getElementsByClassName('videoWrapper__video');
var ratio = 9 / 16;
for (var i = 0; i < videos.length; ++i) {
if (i === 0) continue; // remove this its just to show the difference
videos[i].style.height = videos[i].clientWidth * ratio + 'px';
}
}

window.onload = callback();

body {
margin: 0;
}

@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 700;
src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
}

@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 800;
src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
}

@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 900;
src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
}

@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: 400;
src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
}

.jan-container {
width: 100%;
font-family: "Roboto Condensed";
}

.jan-container .headline-athletes {
display: flex;
}

.jan-container .headline-athletes div {
position: relative;
width: 50%;
height: 900px;
background: red;
margin: 0 60px 0 0;
display: flex;
flex-direction: column;
}

.jan-container .headline-athletes div .videoWrapper {
width: 100% !important;
height: auto;
}

.jan-container .headline-athletes div .videoWrapper iframe {
/*width: 100% !important;*/
background: green;
/* just for showing the iframe */
}

.jan-container .headline-athletes div:last-child {
margin: 0;
}

<section class="jan-container">

<div class="headline-athletes">
<div>
<div class="videoWrapper">
<iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>

<div>
<div class="videoWrapper">
<iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>

</section>








share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53449362%2fvideo-100-width-of-parent-element-auto-height-169%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    i just remembered why i dont like iframes :)



    this should work, you more or less just have to bind the same function to aresize event






    var callback = function() {
    var videos = document.getElementsByClassName('videoWrapper__video');
    var ratio = 9 / 16;
    for (var i = 0; i < videos.length; ++i) {
    if (i === 0) continue; // remove this its just to show the difference
    videos[i].style.height = videos[i].clientWidth * ratio + 'px';
    }
    }

    window.onload = callback();

    body {
    margin: 0;
    }

    @font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 700;
    src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
    }

    @font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 800;
    src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
    }

    @font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 900;
    src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
    }

    @font-face {
    font-family: 'Roboto Condensed';
    font-style: normal;
    font-weight: 400;
    src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
    }

    .jan-container {
    width: 100%;
    font-family: "Roboto Condensed";
    }

    .jan-container .headline-athletes {
    display: flex;
    }

    .jan-container .headline-athletes div {
    position: relative;
    width: 50%;
    height: 900px;
    background: red;
    margin: 0 60px 0 0;
    display: flex;
    flex-direction: column;
    }

    .jan-container .headline-athletes div .videoWrapper {
    width: 100% !important;
    height: auto;
    }

    .jan-container .headline-athletes div .videoWrapper iframe {
    /*width: 100% !important;*/
    background: green;
    /* just for showing the iframe */
    }

    .jan-container .headline-athletes div:last-child {
    margin: 0;
    }

    <section class="jan-container">

    <div class="headline-athletes">
    <div>
    <div class="videoWrapper">
    <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
    </div>
    </div>

    <div>
    <div class="videoWrapper">
    <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
    </div>
    </div>
    </div>

    </section>








    share|improve this answer


























      1














      i just remembered why i dont like iframes :)



      this should work, you more or less just have to bind the same function to aresize event






      var callback = function() {
      var videos = document.getElementsByClassName('videoWrapper__video');
      var ratio = 9 / 16;
      for (var i = 0; i < videos.length; ++i) {
      if (i === 0) continue; // remove this its just to show the difference
      videos[i].style.height = videos[i].clientWidth * ratio + 'px';
      }
      }

      window.onload = callback();

      body {
      margin: 0;
      }

      @font-face {
      font-family: 'Montserrat';
      font-style: normal;
      font-weight: 700;
      src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
      }

      @font-face {
      font-family: 'Montserrat';
      font-style: normal;
      font-weight: 800;
      src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
      }

      @font-face {
      font-family: 'Montserrat';
      font-style: normal;
      font-weight: 900;
      src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
      }

      @font-face {
      font-family: 'Roboto Condensed';
      font-style: normal;
      font-weight: 400;
      src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
      }

      .jan-container {
      width: 100%;
      font-family: "Roboto Condensed";
      }

      .jan-container .headline-athletes {
      display: flex;
      }

      .jan-container .headline-athletes div {
      position: relative;
      width: 50%;
      height: 900px;
      background: red;
      margin: 0 60px 0 0;
      display: flex;
      flex-direction: column;
      }

      .jan-container .headline-athletes div .videoWrapper {
      width: 100% !important;
      height: auto;
      }

      .jan-container .headline-athletes div .videoWrapper iframe {
      /*width: 100% !important;*/
      background: green;
      /* just for showing the iframe */
      }

      .jan-container .headline-athletes div:last-child {
      margin: 0;
      }

      <section class="jan-container">

      <div class="headline-athletes">
      <div>
      <div class="videoWrapper">
      <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
      </div>
      </div>

      <div>
      <div class="videoWrapper">
      <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
      </div>
      </div>
      </div>

      </section>








      share|improve this answer
























        1












        1








        1






        i just remembered why i dont like iframes :)



        this should work, you more or less just have to bind the same function to aresize event






        var callback = function() {
        var videos = document.getElementsByClassName('videoWrapper__video');
        var ratio = 9 / 16;
        for (var i = 0; i < videos.length; ++i) {
        if (i === 0) continue; // remove this its just to show the difference
        videos[i].style.height = videos[i].clientWidth * ratio + 'px';
        }
        }

        window.onload = callback();

        body {
        margin: 0;
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 700;
        src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 800;
        src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 900;
        src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Roboto Condensed';
        font-style: normal;
        font-weight: 400;
        src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
        }

        .jan-container {
        width: 100%;
        font-family: "Roboto Condensed";
        }

        .jan-container .headline-athletes {
        display: flex;
        }

        .jan-container .headline-athletes div {
        position: relative;
        width: 50%;
        height: 900px;
        background: red;
        margin: 0 60px 0 0;
        display: flex;
        flex-direction: column;
        }

        .jan-container .headline-athletes div .videoWrapper {
        width: 100% !important;
        height: auto;
        }

        .jan-container .headline-athletes div .videoWrapper iframe {
        /*width: 100% !important;*/
        background: green;
        /* just for showing the iframe */
        }

        .jan-container .headline-athletes div:last-child {
        margin: 0;
        }

        <section class="jan-container">

        <div class="headline-athletes">
        <div>
        <div class="videoWrapper">
        <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
        </div>
        </div>

        <div>
        <div class="videoWrapper">
        <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
        </div>
        </div>
        </div>

        </section>








        share|improve this answer












        i just remembered why i dont like iframes :)



        this should work, you more or less just have to bind the same function to aresize event






        var callback = function() {
        var videos = document.getElementsByClassName('videoWrapper__video');
        var ratio = 9 / 16;
        for (var i = 0; i < videos.length; ++i) {
        if (i === 0) continue; // remove this its just to show the difference
        videos[i].style.height = videos[i].clientWidth * ratio + 'px';
        }
        }

        window.onload = callback();

        body {
        margin: 0;
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 700;
        src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 800;
        src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 900;
        src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Roboto Condensed';
        font-style: normal;
        font-weight: 400;
        src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
        }

        .jan-container {
        width: 100%;
        font-family: "Roboto Condensed";
        }

        .jan-container .headline-athletes {
        display: flex;
        }

        .jan-container .headline-athletes div {
        position: relative;
        width: 50%;
        height: 900px;
        background: red;
        margin: 0 60px 0 0;
        display: flex;
        flex-direction: column;
        }

        .jan-container .headline-athletes div .videoWrapper {
        width: 100% !important;
        height: auto;
        }

        .jan-container .headline-athletes div .videoWrapper iframe {
        /*width: 100% !important;*/
        background: green;
        /* just for showing the iframe */
        }

        .jan-container .headline-athletes div:last-child {
        margin: 0;
        }

        <section class="jan-container">

        <div class="headline-athletes">
        <div>
        <div class="videoWrapper">
        <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
        </div>
        </div>

        <div>
        <div class="videoWrapper">
        <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
        </div>
        </div>
        </div>

        </section>








        var callback = function() {
        var videos = document.getElementsByClassName('videoWrapper__video');
        var ratio = 9 / 16;
        for (var i = 0; i < videos.length; ++i) {
        if (i === 0) continue; // remove this its just to show the difference
        videos[i].style.height = videos[i].clientWidth * ratio + 'px';
        }
        }

        window.onload = callback();

        body {
        margin: 0;
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 700;
        src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 800;
        src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 900;
        src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Roboto Condensed';
        font-style: normal;
        font-weight: 400;
        src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
        }

        .jan-container {
        width: 100%;
        font-family: "Roboto Condensed";
        }

        .jan-container .headline-athletes {
        display: flex;
        }

        .jan-container .headline-athletes div {
        position: relative;
        width: 50%;
        height: 900px;
        background: red;
        margin: 0 60px 0 0;
        display: flex;
        flex-direction: column;
        }

        .jan-container .headline-athletes div .videoWrapper {
        width: 100% !important;
        height: auto;
        }

        .jan-container .headline-athletes div .videoWrapper iframe {
        /*width: 100% !important;*/
        background: green;
        /* just for showing the iframe */
        }

        .jan-container .headline-athletes div:last-child {
        margin: 0;
        }

        <section class="jan-container">

        <div class="headline-athletes">
        <div>
        <div class="videoWrapper">
        <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
        </div>
        </div>

        <div>
        <div class="videoWrapper">
        <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
        </div>
        </div>
        </div>

        </section>





        var callback = function() {
        var videos = document.getElementsByClassName('videoWrapper__video');
        var ratio = 9 / 16;
        for (var i = 0; i < videos.length; ++i) {
        if (i === 0) continue; // remove this its just to show the difference
        videos[i].style.height = videos[i].clientWidth * ratio + 'px';
        }
        }

        window.onload = callback();

        body {
        margin: 0;
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 700;
        src: local('Montserrat Bold'), local('Montserrat-Bold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_dJE3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 800;
        src: local('Montserrat ExtraBold'), local('Montserrat-ExtraBold'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_c5H3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 900;
        src: local('Montserrat Black'), local('Montserrat-Black'), url(https://fonts.gstatic.com/s/montserrat/v12/JTURjIg1_i6t8kCHKm45_epG3gnD-w.ttf) format('truetype');
        }

        @font-face {
        font-family: 'Roboto Condensed';
        font-style: normal;
        font-weight: 400;
        src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url(https://fonts.gstatic.com/s/robotocondensed/v16/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7CA.ttf) format('truetype');
        }

        .jan-container {
        width: 100%;
        font-family: "Roboto Condensed";
        }

        .jan-container .headline-athletes {
        display: flex;
        }

        .jan-container .headline-athletes div {
        position: relative;
        width: 50%;
        height: 900px;
        background: red;
        margin: 0 60px 0 0;
        display: flex;
        flex-direction: column;
        }

        .jan-container .headline-athletes div .videoWrapper {
        width: 100% !important;
        height: auto;
        }

        .jan-container .headline-athletes div .videoWrapper iframe {
        /*width: 100% !important;*/
        background: green;
        /* just for showing the iframe */
        }

        .jan-container .headline-athletes div:last-child {
        margin: 0;
        }

        <section class="jan-container">

        <div class="headline-athletes">
        <div>
        <div class="videoWrapper">
        <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
        </div>
        </div>

        <div>
        <div class="videoWrapper">
        <iframe class="videoWrapper__video" src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
        </div>
        </div>
        </div>

        </section>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 16:48









        Dirk

        679212




        679212






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53449362%2fvideo-100-width-of-parent-element-auto-height-169%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Lallio

            Futebolista

            Jornalista