2015-03-31 97 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;