2012-07-20 57 views
0

HTML:如何把按鈕放在溢出隱藏div的末尾?

<div id="content"> 
content ,content,content ,content... 
<input type="button" value="see more"> 
</div> 

css 

#content 
{ 
     width:500px; 
    height:400px;/* actual height 1000px */ 
    float:left; 
    color:grey; 
    text-align:justify; 
    text-indent:1em; 
    border:1px solid black; 
    padding:10px; 
     overflow:hidden; 
} 

點擊按鈕使用jQuery在div將擴大高達1000像素。但我的問題是,通過設置overflow:hidden,該按鈕不可見。 我想按鈕顯示在div的結尾。點擊之前和點擊之後,我想在div末尾顯示按鈕。這個怎麼做?

回答

2
#content{ 
    position: relative; 
} 
input[type='button']{ 
    position: absolute; 
    bottom: 0; 
} 

絕對定位的元素相對於最近的「非靜態」定位的父元素進行定位。這就是爲什麼我們需要首先將#content設置爲relative

DEMO:http://jsfiddle.net/RFFwy/

+0

@prash - 做了一個演示的jsfiddle有你了。 – ahren 2012-07-20 04:50:48