我正在使用...使 div 居中
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", (($(window).height() - this.outerHeight()) / 2) +
$(window).scrollTop() + "px");
this.css("left", (($(window).width() - this.outerWidth()) / 2) +
$(window).scrollLeft() + "px");
return this;
}
然后我想将另一个 div 移动到这个居中的 div 的正上方,这样它们就可以如下放置......
|-------------|
| Moved Above |
|-------------|
| |
| Centered |
| |
|-------------|
我将如何实现这一目标?
最佳答案
您可以使用 jQuery 的 prepend()或 prependTo()将新内容置于当前内容之上的功能。
关于javascript - 使 div 总是直接出现在另一个 div 之上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9453347/