0
我有两个div,我想使用相对定位彼此重叠。将两个相对定位的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%'
});
我假设你正在修改使用JavaScript的CSS?作为定位点的div应该是相对的,其他则是绝对的。 – Yisela
@yisela哪一个是定位点?包含背景和前景div的那个?因此,后台和前台是否应该是绝对的?或者我应该在另一个div中包括前台和后台? – lowerkey