2015-08-19 50 views
0

好的项目我需要在运行时渲染一个居中的图像(播放按钮),取决于UserAgent的视频。如果userAgent不是Firefox,我想显示图像,因为Firefox在开始时有自己的playEvent和按钮。我之前所做的所有尝试都失败了。视频标签上的居中图像

我想:在视频标签

  • 标签,并把z-index的10个,而把视频的z-index为1
  • 把一个div与视频标签周围的背景图像

有没有其他的方法可以做到这一点,请不要回复使用海报,因为我已经有我需要使用的海报。

CNC中

代码:

<tr> 
    <td runat="server" width="680px" height="383px" id="vContainer"> 
     <video id="player" style="z-index: 1" width="100%" height="100%" title="" controls runat="server"> 
      <source runat="server" id="ffVideo" type="video/ogg" /> 
      <source runat="server" id="mp4Video" type="video/mp4" /> 
     </video> 
     <embed id="playerOld" width="680px" autostart="false" allowfullscreen="true" height="383px" title="" style="display: none" type="application/mp4" runat="server" /> 
    </td> 
</tr> 
+0

分享您的尝试。具有propper z-index的简单图层可以工作。 –

+0

它应该和我可以在呈现的HTML中找到它在视频背后。 – DieVeenman

+0

有没有''标签在哪里... –

回答

1

为把一个标签,并赋予它更多的z-index一样简单。你可以把它运行:http://jsfiddle.net/65rda3jq/

<div class="cont"> 
    <div class="img"></div> 
    <video id="player" style="z-index: 1" width="100%" height="100%" title="" controls 
     runat="server"> 
     <source runat="server" id="ffVideo" type="video/ogg" /> 
     <source runat="server" id="mp4Video" type="video/mp4" /> 
     </video> 
     <embed id="playerOld" width="680px" autostart="false" allowfullscreen="true" height="383px" 
     title="" style="display: none" type="application/mp4" runat="server" /> 
</div> 

CSS

.cont { 
    position:relative; 
} 

video { position: relative; } 
.img {z-index:10; background: #f00; position: absolute; top: 50%; left: 50%; width: 50px; height: 50px; } 
1

试试这个:

HTML:

<div class="cont"> 
    <div class="img"><span class='play_icon'></span></div> 
    <video id="player" style="z-index: 1" width="100%" height="100%" title="" controls 
     runat="server"> 
     <source runat="server" id="ffVideo" type="video/ogg" /> 
     <source runat="server" id="mp4Video" type="video/mp4" /> 
     </video> 
     <embed id="playerOld" width="680px" autostart="false" allowfullscreen="true" height="383px" 
     title="" style="display: none" type="application/mp4" runat="server" /> 
</div> 

CSS:

.cont { 
    position:relative; 
    background:rgba(42,42,42,0.9); 
    border:none; 
    color:#fff; 
    outline: none; 
} 
.play_icon{ 
    width: 0; 
    height: 0; 
    border-top: 20px solid transparent; 
    border-bottom: 20px solid transparent; 
    border-left: 36px solid #fc8b02; 
    margin: auto; 
    position: absolute; 
    left:0; 
    right: 0; 
    top: 0; 
    bottom: 0; 
} 

video { position: relative; } 
.img { 
    margin: auto; 
    position: absolute; 
    left:0; 
    right: 0; 
    top: 0; 
    bottom: 0; 
    width: 10%; 
    height: 16%; 
    cursor: pointer; 
    border-radius: 5px; 
    background: rgba(0,0,0,0.6); 
} 

http://jsfiddle.net/Grald/kgwvupjm/