gpt4 book ai didi

javascript - 使 div 总是直接出现在另一个 div 之上?

转载 作者:行者123 更新时间:2023-11-28 18:50:35 24 4
gpt4 key购买 nike

我正在使用...使 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com