JQuery Div 高度垂直增加尺寸
我试图让 div 增加高度,但向上而不是向下移动,这种情况几乎每秒都会发生(在实时事件中):
height++;
$("#bar").height(height);
但是现在,框的顶部保持在相同的位置,而栏的底部则移动向下。我希望条形图的底部保持在原来的位置,而顶部则随着每个事件而向上移动。我希望这是有道理的,任何建议都会有所帮助,谢谢!
更新:栏的 CSS:
#bar
{
width:20px;
height:0px;
display: block;
background-color: blue;
}
I am trying to get a div to increase in height but moving upwards instead of downwards, this happens almost every second (on a realtime event):
height++;
$("#bar").height(height);
But right now the top of the box stays in the same position while the bottom of the bar goes down. I want the bottom of the bar to stay where it is while the top moves up with each event. I hope this makes sense, any advice would help thank you!
UPDATE: The CSS of the bar:
#bar
{
width:20px;
height:0px;
display: block;
background-color: blue;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
div
将从下到上进行动画处理,除非您通过底部 css 样式附加它。例如http://jsfiddle.net/robert/BWwyf/
那么
这将从顶部到动画底部
The
div
will animate bottom to top unless you attach it by the bottom css style. For examplehttp://jsfiddle.net/robert/BWwyf/
then
This will animate from the top to the bottom
Pete,
让它绝对定位并给底部一些像素,所以它总是呆在那里,
使这个父div相对
Pete ,
Make it position absolute and give the bottom some pixel, so it always stays there
make this parent div relative