我想知道如何让广告在此网站中显示: http://www.kraniem.lv/ 只是不要点击X,否则广告将关闭,并且只会在第二天再次显示。
答案 0 :(得分:1)
的CSS:
#ad{
position: absolute; /* Or position:fixed; */
z-index: 2;
}
jQuery的:
$(document).ready(function(){
$("#ad").css("top", (($(window).height() - $("#popup").outerHeight() ) / 2) + 'px');
$("#ad").css("left",(($(window).width() - $("#popup").outerWidth() )/ 2 ) + 'px');
});
请注意,如果您想使用图片,则需要将其写为:
$("#ad").css("top", (($(window).height() - $("#popup").outerHeight() - imgheight) / 2) + 'px');
因为基本上,文档dom加载后图像会加载,所以我通常将图像高度解析为其中一个属性,所以我会知道要减去什么。
请注意,该链接对我不起作用,所以我只是根据我以前的作品写作。
编辑: 制作 UI屏幕块:
CSS:
#blanket{
position:absolute;
left:0px;
top:0px;
opacity:0.7;
z-index:1;
width: 100%;
}
jQuery的:
$("#blanket").css("height", $(document).height() + 'px');
HTML:
<div id="blanket"></div>
<div id="popup"></div>