我有一个div元素的视频播放器。我想禁用除DIV之外的所有内容。一种方法是使用灯箱,但我想知道如果我可以使用纯HTML/Javascript来做到这一点。禁用除DIV元素以外的所有内容
2
A
回答
2
我做了简单的例子给你,
jQuery的;
$(".disable").on('click', function(){
// * = select All, find Div, Not (#video) and edit css opacity
$("*").find('div').not("#video").css('opacity', '0.1');
});
HTML;
<button class="disable">Disable</button>
<div class="header">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
<div id="video">
<img src="http://fandomania.com/wp-content/uploads/2012/04/06/anarchy01.jpg">
</div>
<div class="footer">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
的CSS;
.header{border:1px solid #000;background:#cc0000;color:#fff;}
.footer{border:1px solid #000;background:#cc0000;color:#fff;}
检查FIDDLE
+0
只是为了说明这对于一般情况不起作用:您最终将“opacity:0.1”设置为“ #video' –
4
要真正彻底地跨浏览器,你需要一个iframe
,你可以动态创建。除了视频div
之外,使iframe
z-index
高于页面上的其他任何内容,使iframe
为视口/页面的完整大小,然后使视频div
高于z-index
。现在,除视频div
以外的所有点击都会转到iframe
,这可能会忽略它们。如果您想“淡出”页面的其余部分,也可以在iframe上使用不透明度。
大致来说:
function maskAllExcept(div) {
var iframe = document.createElement('iframe');
iframe.style.position = "absolute";
iframe.style.left = iframe.style.right = iframe.style.top = iframe.style.bottom = "0";
iframe.style.zIndex = 1000;
div.style.zIndex = 1001;
document.body.appendChild(iframe);
}
0
这可能会帮助你
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<div id="popup" class="popup">
<div id="large_map_canvas" style="width:550px; height:550px;" align="right"><iframe align="center" src="your url for video" style="width:545px; height:523px; overflow:hidden;"></iframe></div>
</div>
<a href="javascript:void(0)" onclick="showPopup();">Click to view larger map </a>
</td>
</tr>
</table>
<div id="mainDiv" class="businessDetail-backStyle" style="display:none;"> </div>
<script type="text/javascript">
function showPopup() {
document.getElementById('popup').style.display = 'block';
document.getElementById('mainDiv').style.display = 'block';
}
function hidePopup(){
document.getElementById('popup').style.display = 'none';
document.getElementById('mainDiv').style.display = 'none';
}
</script>
<style type="text/css">
.popup {
position:absolute;
top:0%;
left:37%;
margin:-50px 0 0 -100px;
padding:11px;
display:none;
background:#FFF;
z-index:9999;
}
.businessDetail-backStyle
{
background-color: #333333;
opacity: 90%;
filter:alpha(opacity=90);
background-color: rgba(0,0,0,0.737);
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
color: white;
z-index:999;
}
</style>
相关问题
- 1. 轻松转换除一个元素以外的所有内容
- 2. 更新所有div元素的内容
- 3. 删除容器外的所有元素?
- 4. 选择除一个div的所有元素及其内容
- 5. CSS克隆除div以外的所有内容
- 6. 如何使用jQuery定位除1元素以外的所有内容?
- 7. 除了点击元素之外,选择div内的所有其他元素
- 8. 如何禁用页面的所有元素,除了2 div
- 9. jQuery选择除了一个元素以外的所有元素
- 10. 如何禁用除所选单元之外的所有单元
- 11. 点击某个链接时,如何去除外部元素和外部元素内的所有内容?
- 12. 从div元素中删除内容
- 13. jQuery:禁用div内的所有链接 - 替换内部内容
- 14. jQuery获取div内容的文本和元素,但某些元素除外
- 15. 使用外部内容填充div和子div元素
- 16. 抓住div内的所有fieldset元素
- 17. 显示div内的所有元素?
- 18. VI删除除模式以外的所有内容
- 19. PHP从阵列中删除除x以外的所有内容
- 20. PHP删除除字符串以外的所有内容
- 21. 删除除VIM中第一列以外的所有内容
- 22. Shell - 删除除单个文件夹以外的所有内容
- 23. 删除除元素之外的所有元素
- 24. JQuery .ajax GET适用于除IE以外的所有内容
- 25. 使用Perl剥离除html标签以外的所有内容
- 26. 使用阵列中除了一个以外的所有元素
- 27. 首先显示所有<tr>元素,然后隐藏除一个类以外的所有内容
- 28. jQuery - 选择除了一个div以外的页面上的所有内容
- 29. 如何编写xpath以匹配除特定元素以外的所有元素
- 30. 使用Javascript选择除了一个元素以外的所有元素
你可能想告诉我们这里的一些代码? – Severin
Errrrrmmmmm,你到底想做什么? – Mike
创建被屏蔽的div,将其设置为超过9000等级的z-index – DarkBee