【问题标题】:How to add button overLay in Video Tag如何在视频标签中添加按钮叠加
【发布时间】:2015-03-14 13:54:38
【问题描述】:

我在video 标签中添加了一个 div 并使用了 CSS,但它不起作用。我已经引入了 javascript 来播放/停止点击视频。我想在播放器中间显示一个按钮。类似this

#player_buttons
{
    width: 128px;
    height: 128px;
    z-index: 99;
    background: url('http://cdn1.iconfinder.com/data/icons/iconslandplayer/PNG/64x64/CircleBlue/Play1Pressed.png') center center no-repeat;
}

【问题讨论】:

    标签: javascript jquery html css html5-video


    【解决方案1】:

    我认为您不能/不应该将内容放在视频源以外的视频元素中,除非您希望该内容显示在不支持视频标签的浏览器中。取自规格:

    可以在视频元素内提供内容;它旨在用于 不支持视频的旧 Web 浏览器,因此旧版视频 可以尝试插件,或者向这些老用户显示文本 浏览器通知他们如何访问视频内容

    http://dev.w3.org/html5/spec-author-view/video.html#video

    但是通过用容器包装视频元素并将overlay-div附加到该容器,您可以通过position:absolutez-index堆叠它们。

    您可以在此处查看示例:http://jsfiddle.net/vtrzmf92/

    更新的 HTML:

    <div class="container">
        <video src="#" width="800" height="600"></video>
        <div class="player-buttons"></div>
    </div>
    

    更新的 CSS:

    .container{
        position: relative;
    }
    
    .container>.player-buttons{
        background: url('http://cdn1.iconfinder.com/data/icons/iconslandplayer/PNG/64x64/CircleBlue/Play1Pressed.png') center center no-repeat;
        height: 128px;
        left: 50%;
        margin: -64px 0 0 -64px;
        position: absolute;
        top: 50%;
        width: 128px;
        z-index: 1; 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-31
      • 2013-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多