html - YouTube缩略图+ Playicon链接

标签 html facebook youtube

最近,我在Facebook上看到了指向嵌入了YouTube的外部网站的链接,该链接在时间轴上显示了一个巨大的视频缩略图+一个YouTube播放图标。

这是屏幕截图:

我试图做一些研究,也做了一些测试,看看是否仅仅是Facebook做的,但是我找不到正确的解决方案。

你们中有人知道吗?

最佳答案

试试这个:

<style>
   .oVideo {
      width: 300px;
      height: 150px;
      background-color: #f00;
      position: relative;
   }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

<div class="oVideo">
   <!-- INSERT PREVIEW AND PLAY IMAGE HERE WITH AN ABSOLUTE POSITION -->
</div>

<script>
   $(document).ready(function () {
      $('.oVideo').click(function () {
         var video = '<iframe src="http://www.youtube.com/embed/6TgyvSQlJtI?wmode=transparent&enablejsapi=1&rel=0&autohide=1&autoplay=1" frameborder="0" allowfullscreen id="video"></iframe>';
         $('.oVideo').html(video);
         // REMOVE THE PREVIEW AND PLAY IMAGE ELEMENTS HERE
      });
   });
</script>

然后只需在'.oVideo'元素中添加预览图像和播放按钮图像,并在叠加层上单击时将其隐藏。

关于html - YouTube缩略图+ Playicon链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22090771/

相关文章:

html - Facebook 三 Angular 箭头

api - 我可以在 youtube 上上传视频并将其限制为只能在我的网站上观看吗?

php - SQL 数据库未更新并收到错误消息,新手不知道为什么?

html - XSLT:转换成非 XML 内容?

javascript - Mootools 登录 facebook

facebook - 来自 Facebook 的网站 Paypal 按钮

html - 列表上的神秘边距或填充

javascript - 如何使用jquery将图像显示为html文件? (一些 php 和 xml)

iframe - YouTube嵌入式视频自动播放

video - Youtube/Netflix 如何流式传输视频?