HTML : play a video inside an image -


i'm trying play video inside png image of tv tv serves frame video.

i tried that, pushes tv image , plays video underneath.

<img class="tv" src="images/tv.png" alt="tv">   <video width="320" height="240">     <source src="video/video.mp4" type="video/mp4" />   </video> </img>   

can me finding way in there ? because i'm sure there easy solution, don't know look. thank !

first of all, can't use <img> way, because it's element can't contain other elements.

all have put image background div , display video correct position:

<div id="tv_container">     <video width="320" height="240">         <source src="video/video.mp4" type="video/mp4" />     </video> </div>  <style> #tv_container {     background: url('images/tv.png') no-repeat top left transparent;     width: 400px; /* adjust tv image width */     height: 300px; /* adjust tv image height */     position: relative; } #tv_container video {     position: absolute;     top: 30px; /* adjust top position */     left: 40px; /* adjust left position */ } </style> 

or instead of position: relative; , position: absolute; can use margin: 30px 0px 0px 40px; #tv_container video (but trick position better when want add more element #tv_container.

i assumed tv image bigger video, have adjust few things display correctly.


inspired guilherme j santos' answer, suggest use tv image layer on video, because in way can use image tv screen doesn't have strict rectangle. of course part of video cropped then, tv screen.

<div id="tv_container">     <video width="320" height="240">         <source src="video/video.mp4" type="video/mp4" />     </video> </div>  <style> #tv_container {     width: 400px; /* adjust tv image width */     height: 300px; /* adjust tv image height */     position: relative; } #tv_container:after {     content: '';     display: block;     background: url('images/tv.png') no-repeat top left transparent;     width: 100%;     height: 100%;     left: 0px;     top: 0px;     position: absolute;     z-index: 10; } #tv_container video {     position: absolute;     top: 30px; /* adjust top position */     left: 40px; /* adjust left position */     z-index: 5; } </style> 

be sure z-index of layer (which in case #tv_container:after pseudo-element) greater video's z-index. and there's 1 thing: video not clickable (because it's under layer) according @brichins's comment it's possible make video clickable under layer (thanks!).

of course screen part of tv must transparent!


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -