gpt4 book ai didi

html - 将两个相对定位的 div 堆叠在一起

转载 作者:太空宇宙 更新时间:2023-11-04 15:54:35 26 4
gpt4 key购买 nike

我有两个 div,我想使用相对定位将它们放在彼此之上。

<div id="display_background">
</div>
<div id="display_foreground">
<div id="home">
This is the home page
</div>

<div id="info">
This is the info page
</div>

<div id="contact">
This is the contact page
</div>
</div>

我正在尝试堆叠它们,并使用相对定位,因为我希望 div 位置随背景图像进行调整。

这是我正在使用的 CSS:

$('#display_background').css({
'background-color': 'white',
opacity: 0.5,
position: 'relative',
left: '66%',
top: '66%',
width: '425px',
height: '330px',
border: '1px solid'
});
$('#display_foreground').css({
position: 'relative',
left: '66%',
top: '66%',
width: '20%',
height: '25%'
});

最佳答案

您可以尝试将位置更改为绝对位置并添加具有相对位置的包装器。看这个例子: http://jsfiddle.net/fKmYN/19/你好,吉乔伊

关于html - 将两个相对定位的 div 堆叠在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10727958/

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