指定div的JavaScript图像叠加层 [英] javascript image overlay over a specified div
问题描述
我是新的javascript。非常新的,实际上,这应该是我的第一个脚本。
任何人都可以向我解释如何在任何指定的固定宽度区域,如700x300像素上做一个透明覆盖。
i am new at javascript. very new actually, this ought to be my first script. can anyone explain to me how to make a transparent overlay over any specified fixed width region, say 700x300px.
推荐答案
您可以定义重叠,例如
<div id="myoverlay" class="myoverlay">...contents...</div>
并在CSS中定义尺寸和位置以及z-index等...
and define the dimensions and position and z-index etc... in CSS
.myoverlay {
position: absolute;
display: none;
...
}
我不太明白JavaScript,但我想你会想使用JS来切换叠加层的显示属性on / off。
I don't quite see the need for JavaScript just yet, but I guess you will want to use JS to toggle the overlay's display attribute on/off.
<script type="text/javascript">
function showOverlay(){
document.getElementById("myoverlay").style.display = "block";
}
</script>
这大概是什么?对不起,无意的语法错误,因为这是未经测试的代码纯粹在我的头顶。只是给你一个想法。
Is this roughly what you're after? Sorry for unintentional syntax mistakes, for this is untested code purely off the top of my head. Just to give you an idea.
这篇关于指定div的JavaScript图像叠加层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!