简体   繁体   English

如何将div置于父div的顶部

[英]How to stick div to the top of parent div

What I'm trying to do is, 我想做的是

  • always stick class="new" div to the top of .inside div when you scroll down. 向下滚动时,请始终将class="new" div粘贴到.inside div的顶部。
  • When you click on new div, create new row inside (at the top of table not at the bottom like now) 当您单击新的div时,在其中创建新行(在表格顶部而不是现在的底部)

http://jsfiddle.net/tt13/5CxPr/13/ http://jsfiddle.net/tt13/5CxPr/13/

Here is a fiddle of what you want to achieve. 是您想要实现的目标的小提琴。 Use prependTo instead of appendTo and use position:absolute;top:0; 使用prependTo代替appendTo并使用position:absolute;top:0; for keeping it on the top 保持在顶部

使用prependTo()而不是appendTo() http://jsfiddle.net/uday99/5CxPr/20/

try this one instead 试试这个

the code is too long to put here but here are key notes: 该代码太长,无法放置在此处,但以下是一些关键说明:

  • to append to the top, use .prependTo() 要追加到顶部,请使用.prependTo()
  • separate the new button and create a scrollable div below it 分离新按钮并在其下方创建一个可滚动的div

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM