gpt4 book ai didi

jquery - 页面顶部的 div 在其他顶部 div 之前

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

如何在 firstClass 之前强制使用 secondClass,即使 first class 具有相同的最高值?如果可能的话,使用 jquery 或 css hack。 firstClass 的值可能与本例中不同,但 secondClass 的值是固定的。

<html>
<body>
<div class="firstClass">Hello</div>
<div class="secondClass">This is Warning!</div>
</body>
</html>

和CSS

.firstClass {
position: fixed;
top: 0px;
}

.secondClass {
position: fixed;
top: -25px;
}

在线演示 http://jsfiddle.net/AQUgk/

谢谢。

最佳答案

使用 CSS 在屏幕上移动它:

$(".firstClass").css('top', $(".secondClass").height());
$(".secondClass").css('top', 0);

如果移动 DOM 中的元素是您想要的:

$(".firstClass").before($(".secondClass"));

FIDDLE

关于jquery - 页面顶部的 div 在其他顶部 div 之前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10162318/

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