Skip to content Skip to sidebar Skip to footer

How To Prevent Iframe Video Go Beyond Max-width & Max-height?

I embedded a responsive youtube video with bootstrap. My aim: keep it's max size width='560' height='315' which is then centered. How it should be: https://avexdesigns.com/respons

Solution 1:

If understood it correctly you want something like this:

#embed {
    height: auto;

    text-align: center;
    background: black;
    width: 100%; /* new */
    max-width: 560px; /* new */
    margin: 0 auto; /* new */
}


.videowrapper {
    float: none;
    clear: both;
    width: 100%;
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 25px;
    height: 0;
}

.videowrapper iframe, .videowrapper object, .videowrapper embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
<section id="embed">


                  <div class="container-fluid videowrapper">

                  <iframe src="https://www.youtube.com/embed/g42lHnzOeVs" width="560" height="315" frameborder="0" allowfullscreen=""></iframe>
                  </div>


</section>

Post a Comment for "How To Prevent Iframe Video Go Beyond Max-width & Max-height?"