【发布时间】:2016-03-24 06:03:02
【问题描述】:
我有这个大问题。
我正在制作一个学校项目网站,我需要放置一些相互重叠的 div,起初只需在 CSS 中放置“位置:绝对”就足够了。
但是教授说使用 position:absolute 会在更改窗口大小时出现问题,所以我不得不删除它,现在所有的 div 都在另一个之下,有没有办法让它们重叠而不使用 position :absolute,他告诉我的一件事是使用 Jquery.. 但是如何?
aniway,很抱歉缺少代码,但这里是:
代码如下: 这是各个div的划分
<div id="demo">
<div id="schermo"></div>
<div id="titlescreen"></div>
<div id="porta_destra"></div>
<div id="porta_sinistra"></div>
<div id="schermo_vetro"></div>
<div id="schermo_bordi"></div>
</div>
这是 CSS 格式
#demo {
width: 800px;
height:600px;
padding: 8px;
margin:0 auto;
}
#porta_sinistra {
position: relative;
width: 350px;
height: 600px;
background: url(../img/porta.jpg) no-repeat; background-size: cover;
}
#porta_destra {
position: relative;
width: 350px;
height: 600px;
background: url(../img/porta.jpg) no-repeat; background-size: cover;
}
#titlescreen{
position: relative;
width: 650px;
height: 500px;
background: url(../img/titlescreen.jpg) no-repeat;background-size: cover;
margin:0 auto;
}
#schermo{
position: relative;
width: 800px;
height: 600px;
background: url(../img/schermo.png) no-repeat; background-size: cover;background-color: transparent;
margin:0 auto;
}
#schermo_vetro{
position: relative;
width: 800px;
height: 600px;
background: url(../img/schermo_vetro.png) no-repeat; background-size: cover; background-color: transparent;
margin:0 auto;
}
#schermo_bordi{
position: relative;
width: 800px;
height: 600px;
background: url(../img/schermo_bordi.png) no-repeat; background-size: cover;background-color: transparent;
margin:0 auto;
}
但基本上它给了我这个结果: div all one below the other
【问题讨论】: