Safari on iPad (iOS6) does not scale HTML5 video to fill 100% of page width

后端 未结 5 1670
你的背包
你的背包 2020-12-07 13:08

I am using the following CSS to display a video in full width (100%) on a responsive HTML5 page. The native size of the video is 480x270. The video is scaled to fill the ful

5条回答
  •  天涯浪人
    2020-12-07 13:36

    Incorporating part of @brianchirls answer, here's what I did. This seems to be working so far on desktop, Android, and iOS. Take advantage of the responsive padding trick, where padding-top, as a percentage will be a percent of the width. My video is 16:9 so here's my code:

    #video-container {
     position: relative;
     padding-top: 56.25%;
    }
    
    video, object {
      display: block;
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
    }
    

提交回复
热议问题