为什么我的视频在Firefox上而不在Chrome上拉伸?

时间:2018-10-29 10:44:50

标签: angularjs html5 css3 html5-video

我尝试制作横幅视频,该视频将始终以宽度的100%拉伸。它在Firefox上效果很好,但在Chrome上效果不佳。为什么?例如,请参见https://www.gustdive.com。我尝试使用代码段,但是,存在太多的兼容性问题,因此无法正常工作。我可以提供具体示例的唯一方法是链接本身。

感谢@Mav提供了直观的示例!请参阅

Firefox

enter image description here

Chrome

enter image description here

这是我的代码:

<!-- Main Layout Content -->
<md-content md-colors="accent">

    <!-- Tabs Layout -->
    <md-tabs md-selected="ctrl.tabSelected" md-stretch-tabs="always" class="md-primary" md-dynamic-height md-border-bottom>

        <!-- Home Tab -->
        <md-tab>

            <!-- Home Tab Label -->
            <md-tab-label>
                <h2>
                    <md-icon md-svg-src="media/image/icon/home.svg"></md-icon>
                    <span hide show-gt-sm>
                        &nbsp;Home
                    </span>
                </h2>
            </md-tab-label>

            <!-- Home Tab Body -->
            <md-tab-body>

                <!-- Home Tab Banner -->
                <div layout="column" layout-align="start center" style="overflow-y: hidden; max-height: 275px; text-align: center; background-color: #000;">
                    <div id="banner-title" style="position: absolute;">
                        <img src="media/image/icon/logo-white-192x192.png" alt="GustDive Logo" />
                        <span hide show-gt-xs>
                            <br />
                            <h1 style="font-size: 50px; color: white; text-shadow: 0 0 10px white; letter-spacing: 15px;" flex>
                                GustDive
                            </h1>
                        </span>
                    </div>
                    <video loop muted autoplay style="width: 100%;">
                        <source src="media/video/underwater-720p.mp4" type="video/mp4">
                        <source src="media/video/underwater-360p.mp4" media="(max-width: 640px)" type="video/mp4">
                    </video>
                </div>

                <!-- Home Tab Content -->
                <md-content layout="row" layout-xs="column" layout-wrap>

                </md-content>

            </md-tab-body>

        </md-tab>
    </md-tabs>

    <!-- Website Footer -->
    <div md-colors="{background: 'grey-A200'}" layout-padding>
        <div layout="row" layout-align="end center">
            <a target="_blank" href="https://www.padi.com" aria-label="Padi">
                <img src="media/image/icon/padi.png" alt="Padi" />
            </a>
            <a target="_blank" href="https://www.tripadvisor.com/Attraction_Review-g150793-d11888983-Reviews-GustDive-Puerto_Vallarta.html" aria-label="Trip Advisor">
                <img src="media/image/icon/trip-advisor.png" alt="Trip Advisor" />
            </a>
        </div>
        <div layout-align="center end" style="font-size: 12px; text-align: center;">Copyright © Jonathan-Gagne.com 2018</div>
    </div>

</md-content>

1 个答案:

答案 0 :(得分:0)

使用object-fit: fill在Chrome上将宽度设置为100%。不过,这不适用于IE11(请参见caniuse)。