我需要将一个元素粘合到底部和顶部,但我想从顶部保持另一个元素进入的动态空间,我希望top
是那个元素大小+一些空间。
这怎么可能(首选纯 CSS)?
这是一个例子:
HTML:
<header id="header" class="center">
Hello and welcome to my demo!
</header>
<header id="slider" class="center">
<img src="http://goo.gl/o6tho"/>
</header>
<div id="content" class="center">
I want this area to be glued to the footer + 10px space
And additionally, glued to the element on top of itself + 10px
The slider can disappear, which should result in the content
to grow and reach the heaader.
</div>
<footer class="center">
All rights reserved.
</footer>
CSS:
.center
{
width: 200px;
margin-left: auto;
margin-right: auto;
right: 0px;
left: 0px;
}
#header
{
background: green;
color: white;
height: 50px;
position: fixed;
top: 0px;
}
#slider
{
height: 60px;
position: fixed;
top: 60px;
}
#slider img
{
max-width: 100%;
}
#content
{
background: beige;
height: 50px;
bottom: 10px;
}
footer
{
background: blue;
color: white;
height: 50px;
position: fixed;
bottom:0px;
}