Responsive video iframes (keeping aspect ratio) with only CSS?

后端 未结 4 1479
遥遥无期
遥遥无期 2020-12-08 02:31

I usually use a similar solution to this one. Something like:

.wrapper {
   position: relative;
   width: 100%;
   height: 0;
   padding-bottom: 56.25%;
}
.wr         


        
4条回答
  •  既然无缘
    2020-12-08 03:02

    Here is a Fiddle for a solution, that is based on a CSS2 secret: https://jsfiddle.net/59f9uc5e/2/

    It is explained by how percentage-values for padding are handled:

    The percentage is calculated with respect to the width of the generated box's containing block, even for 'padding-top' and 'padding-bottom'.

    https://www.w3.org/TR/CSS2/box.html#padding-properties

提交回复
热议问题