我有一个标准dojox.mobile.EdgeToEdge
列表,里面有一组dojox.mobile.ListItem
s。我需要确保每个列表项的高度相同。请参阅下面绘制不佳的表示:
EdgeToEdgeList
带s 的标准ListItem
:
+-------------------+
| Standard ListItem |
|-------------------|
| Standard ListItem |
|-------------------|
| Standard ListItem |
|-------------------|
| Standard ListItem |
+-------------------+
EdgeToEdgeList
具有可变高度列表项的标准;通过variableHeight
在列表项上设置属性来实现:
+-------------------+
| Standard ListItem |
|-------------------|
| Standard ListItem |
|-------------------|
| Standard ListItem |
| with some long |
| text and variable |
| height that wraps |
| to next line |
|-------------------|
| Standard ListItem |
+-------------------+
EdgeToEdgeList
具有相等高度的列表项(较小的列表项“占据”最大高度):
+-------------------+
| |
| |
| Standard ListItem |
| |
| |
|-------------------|
| |
| |
| Standard ListItem |
| |
| |
|-------------------|
| Standard ListItem |
| with some long |
| text and variable |
| height that wraps |
| to next line |
|-------------------|
| |
| |
| Standard ListItem |
| |
| |
+-------------------+
我正在尝试复制第三种解决方案。有没有标准的方法来做到这一点?
编辑:我没有提到我正在以编程方式构建列表,所以我事先不知道最大项目的高度。像这样的东西可以吗?
var largest = 0;
array.forEach(list.getChildren(), function(child) {
var childHeight = domStyle.get(child.domNode, 'height');
largest = (childHeight > largest) ? childHeight : largest;
});
array.forEach(list.getChildren(), function(child) {
domStyle.set(child.domNode, 'height', largest + 'px');
});
这似乎有点“hack-y”。