【发布时间】:2015-02-15 18:11:04
【问题描述】:
似乎只有在应用程序模板中使用position: fixed 时才有效,如果我将元素放在其他模板下(比如说索引),它将基于 ember-view 而不是浏览器窗口定位。
那么我如何确保元素保持在当前视图的底部?
谢谢。
解决方案:
感谢@Kalman 提出的条件渲染方法,我花了一些时间,所以我所做的是:
在 application.hbs 下有一个命名的插座:
<div class="position-fixed-bottom">
{{outlet "placeToPutElement"}}
</div>
当在路线中我需要该元素时,使用指定的控制器通过renderTemplate 将其渲染出来:
App.SomeRoute = Ember.Route.extend({
renderTemplate: function()
{
this.render('addbtn', {into:'application', outlet: 'placeToPutElement', controller: 'controllerName'})
//Render other content
}
});
所以当我们调用它时,元素将在应用程序模板中呈现时相对于窗口保持底部。 (记得使用position: fixed)
【问题讨论】:
标签: css ember.js css-position