Javascript move image together with video to other divs [closed]

只愿长相守 提交于 2019-12-13 23:13:14

问题


Before I asked a question how to move videos from one div to another. Now, I have another problem. I want to "attach" an image on each video (actually, I would like to have an image in front of each video) and make it moving together with video.

Instead of pasting my code here, I made a working JSBIN DEMO which could clear the things out. Any possibility of doing this? Anyone could help me?

--- EDIT ---- I have videos, which are moved to other <div>s on mouseclick. Also I want to attach some icons on these videos, so that the images from original <div>s would move to another <div>s together on mouse click when video is clicked.


回答1:


Try placing the image and video into a div together and move the div rather than just the video. Maybe something along the lines of

<div style="height:100;width:100;position:relative;">
   <source src="movie.mp4" type="video/mp4" style="position:absolute;z-index:1;">
   <img src="image.jpg" style="position:absolute;z-index:2;">
</div>

Use the Z-index to hide the video behind the image in the div, then use javascript or jquery to onclick change z-index variable.



来源:https://stackoverflow.com/questions/24509040/javascript-move-image-together-with-video-to-other-divs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!