2015-10-06 79 views
1

我想提出一个textarea在一个div的底部(并固定):textarea的固定div的底部 - CSS

<div id=msg> 

<div id=content> 
    aaaaaaaannnnnnnnnn<br> 
    aaaaaaaannnnnnnnnn<br> 
    aaaaaaaannnnnnnnnn<br> 
</div> 

<div id=text> 
    <textarea></textarea> 
</div> 

</div> 

CSS

#msg{ 
width:60%; 
height:500px; 
float:left; 
background-color:#fff; 
border:1px solid #000; 
} 
#content{ 
overflow-y: auto; 
} 
#text{ 
bottom:0; 
position:fixed; 
} 

为什么底部:0不加工? http://jsfiddle.net/mu1tynax/

+0

的可能的复制[?如何对齐一个div与CSS底部的内容(http://stackoverflow.com/questions/585945/how-to-align-a-div-to-the-bottom-with-css) – JJJ

回答

0

在你的小提琴中,你错过了position: fixed。但是,请注意,固定位置是相对于身体而不是相对的父div。

在您的小提琴中插入位置,它的工作原理。

-1

你需要在你的“文本”div中设置绝对位置,而且在父div中设置相对位置。在定位元素Fiddle

#msg{ 
width:60%; 
height:500px; 
float:left; 
background-color:#fff; 
border:1px solid #000; 
overflow-y: auto; 
    position: relative; 
} 
#text{ 
    position: absolute; 
bottom:0; 
} 

更多信息(绝对)位置:https://css-tricks.com/absolute-positioning-inside-relative-positioning/

+1

不错的副本pasterino – Swag

+0

@TheOddGuy如果我需要复制并粘贴你的答案,那么我应该被解雇我的工作。这是一个非常简单的解决方案。 – deebs