Div被Select挡住,是一个比较常见的问题。有的朋友通过把div的内容放入iframe或object里来解决。
这样会破坏页面的结构,互动性不大好。
另一种方法是:
虽说div直接盖不住select,但是div可以盖iframe,而iframe可以盖select,所以把一个iframe来当作div的底。
相关代码:
- <p class="msg">已添加,您现在还需要继续吗?</p>
- <p><input name="close" οnclick="javascript:hidePop();" type="button" class="btn1"/></p>
- <iframe id="popiframe" style="display:none"></iframe>
- function usershowPop()
- {
- var width = 319; //弹出框的宽度
- var height = 138; //弹出框的高度
- var obj = document.getElementById("msg");
- var obj_iframe = document.getElementById("popiframe");
- obj_iframe.style.display = obj.style.display = "block";
- obj_iframe.style.position = obj.style.position = "absolute";
- obj_iframe.style.zindex = obj.style.zindex = "999";
- obj_iframe.style.width = obj.style.width = width + "px";
- obj_iframe.style.height = obj.style.height = height + "px";
- var p_top = document.documentElement.scrollTop;
- var p_left = document.documentElement.scrollLeft;
- var p_height = document.documentElement.clientHeight;
- var p_width = document.documentElement.clientWidth;
- leftadd = (p_width-width)/2;
- topadd = (p_height-height)/2;
- obj_iframe.style.top = obj.style.top = (p_top + topadd) + "px";
- obj_iframe.style.left = obj.style.left = (p_left + leftadd) + "px";
- window.onscroll = function (){
- obj_iframe.style.top = obj.style.top = (document.documentElement.scrollTop + topadd) +"px";
- obj_iframe.style.left = obj.style.left = (document.documentElement.scrollLeft + leftadd) +"px";
- };
- }
- function userhidePop()
- {
- obj = document.getElementById("msg");
- document.body.removeChild(obj);
- document.getElementById("popiframe").style.display = "none";
- }
这个div就可以盖住select了.