在 CSS 中,我可以使用“position:sticky”使元素具有粘性(滚动时不移动)。 我希望在 Qooxdoo 中获得这种行为。
请参阅Playground获取代码示例。 水平滚动时,应该具有粘性的元素正在移动。 我怎样才能让它粘在Qooxdoo中?
问题不是关于CSS,而是关于Qooxdoo。
我的代码:
var container = new qx.ui.container.Composite(
new qx.ui.layout.Grid()
).set({
padding: 20,
});
this.getRoot().add(container, { edge: 0 });
var sticky = new qx.ui.basic.Label("sticky").set({
padding: 30,
backgroundColor: 'yellow',
});
sticky.getContentElement().setStyle({position: 'sticky'});
var label2 = new qx.ui.basic.Label("Label 2 ").set({
padding: 30,
backgroundColor: 'green',
width: 500
});
container.add(sticky, { row: 0, column: 0 });
container.add(label2, { row: 1, column: 0 });
解决方案是使用“allowShrinkX”属性。