在网页上播放视频,就像点击图像后弹出一样
Play video on webpage like a pop up after clicking image
我需要播放视频时播放按钮被点击。但我需要这个视频在同一个页面上播放,背景淡出。视频需要像弹出视频一样显示。我有问题,让视频来作为一个弹出当图像被点击。当我点击观看视频时,我需要它是这样的。我该怎么做呢?
<div class="col-md-12 f-play-video">
<a href="https://youtu.be/7pvci1hwAx8"><img class="play-button" src="http://www.clipartbest.com/cliparts/bcy/Egx/bcyEgxxzi.png"></a>
</div>
.f-play-video{
text-align: center;
margin-top: 80px;
}
.play-button{
width:50px;
}
https://jsfiddle.net/4dd4ze53/3/我猜模态框会解决你的问题。只需将您的视频代码插入到框中。
<head>
<style>
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
</style>
</head>
<body>
<button id="myBtn">Click here for video!</button>
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p align="center">INSERT YOUR VIDEO HERE!</p>
</div>
</div>
<script>
var modal = document.getElementById('myModal');
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0];
btn.onclick = function() {
modal.style.display = "block";
}
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
@ilmk, @A。Lau和@coskikoz,我设法让弹出工作使用引导模式。这是我的工作代码。
<div class="col-md-12 f-play-video" data-toggle="modal" data-target="#myModal">
<img src="images/play-video.svg">
</div>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Video</h4>
</div>
<div class="modal-body">
<iframe width="100%" height="360" src="<iframe width="560" height="315" src="https://www.youtube.com/embed/7pvci1hwAx8?rel=0&controls=0" "frameborder="0" allowfullscreen autoplay></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
您的示例使用onclick函数在文档末尾创建模型,并在正文顶部创建覆盖元素,然后在模型中添加文本并替换视频链接。
onclick="return playYoutube("Achieve more everyday in your work and your daily life", this.href);"
相关文章:
- 如何像模糊图像一样模糊iframe
- 如何缩放像图像一样的元素
- 将多个画布保存为一个图像(使网站像PicFrame一样)
- 如何使用jquery或javascript让图像从页面的一侧滑动到另一侧?就像在 thepiratebay.se 上一样
- 像在 photoshop 中一样使用可拖动手柄倾斜图像
- 显示图像右侧的文本,就好像图像比实际大一样
- 如果已经声明了宽度,则在页面加载后更改图像宽度?如果未声明宽度,则宽度将更改,但如果像我一样声明,则不会更改
- 在 HTML 中像视频一样显示图像流
- Tumblr和google+如何像拼图一样堆叠图像
- 如何防止 Canvas 在移动设备上表现得像图像一样
- 如何将图像拖到动态之外.js并将其放入,然后像图像一样,或者作为矩形的图案
- 像图像一样拖放画布
- 创建一个图像地图并点击像谷歌地图一样的标记
- 我们如何为“;像facebook一样没有开放图;但我需要张贴标题,描述,图像
- 像单选按钮一样切换图像
- 就像RubyonRails中的按钮Ajax一样——如何更改图像和标志性文本
- 像photoshop一样的混合模式是否可能与html5和可拖动的图像
- 如何使图像地图的区域像复选框一样
- 幻灯片显示,像其他幻灯片一样将图像滑动进来
- 如何在Asp.net中使用c#创建编辑缩略图功能,就像在facebook中一样(同时上传显示图像)