2015-03-31 116 views
0

我有一个div:隐藏屏幕底部的div吗?

<div id="hide-me"> 
    <p>some content</p> 
</div> 

如何使用CSS屏幕的底部位置这一关,我以后打算从底部动画它)。

+0

你可以用'边距:-999px;' – Lal 2015-03-31 17:54:53

+1

很多这里位置的答案没有考虑到你提到,你想动画'#捉迷藏me' DIV账户从底部。如果应用2s动画,那么对于位于视口之外的'#hide-me' div和放置在视口之外的一个'-9999px'之类的结果,结果将会大不相同。 – hungerstar 2015-03-31 18:11:47

+0

这里是我上面提到的一个例子:http://jsfiddle.net/cwwx596x/。调整注意到的底部属性。 – hungerstar 2015-03-31 18:18:02

回答

2

使用position:absolute

#hide-me { 
 
    position: absolute; 
 
    bottom: -99999px; 
 
}
<div id="hide-me"> 
 
    <p>some content</p> 
 
</div>

2
#hide-me { 
position: absolute; 
bottom: 0; 
margin-top: -30px; 
} 
1

您可以使用绝对定位:

#hide-me 
{ 
    position: absolute; 
    bottom: 0; 
    margin-top: -50px; 
} 

但要记住你的HTML & body元素的高度设置为100%!

html, body 
{ 
    height: 100%; 
} 
2

使用

margin-bottom:-999px; 

相对定位的div

或绝对定位的div使用

bottom:-999px;