以较小的分辨率更改DIV垂直位置

时间:2014-02-02 18:34:17

标签: javascript jquery position footer floating

我需要帮助。我有div作为页脚,但没有固定的位置。所以,如果我向下滚动页脚滚动。但如果我减少我的探险家页脚的大小有垂直位置错误。因此,如果探险家的分辨率较小,我需要改变垂直位置。

这是一个例子

HTML:

<div id="header">
MENU
</div>
<div id="content1">
something
</div>
<div id="footer">
</div>
<div id="content2">
something
</div>

CSS:

#header {
width: 500px;
height: 20px;
background: blue;
position: fixed;
}

#content1 {
width: 500px;
height: 560px;
background: grey;
}

#footer {
width: 700px;
height: 40px;
    background: red;
position: absolute;
opacity: 0.5;
bottom: -20px;
}

#content2 {
width: 500px;
height: 560px;
background: green;
}

JSFIDDLE DEMO: http://jsfiddle.net/jiriranc/w89Yc/3/

你知道吗?如果分辨率的大小很大,那么页脚重叠div。但如果分辨率较小,则div不重叠,我需要重叠。

1 个答案:

答案 0 :(得分:1)

使用此CSS

#header {
width: 500px;
height: 20px;
background: blue;
position: fixed;
}

#content1 {
width: 500px;
height: 560px;
background: grey;
}

#footer {
width: 700px;
height: 40px;
background: red;
bottom: -20px;
position:dynamic;
}

#content2 {
width: 500px;
height: 560px;
background: green;
}

并查看http://jsfiddle.net/w89Yc/4/