【发布时间】:2018-08-19 18:08:26
【问题描述】:
feed_page: {
margin: 'auto'
},
feed_list: {
margin: 'auto'
},
feed_item: {
textAlign: 'center',
backgroundColor: '#fff',
borderBottom: '1px solid #e0e0e0',
margin: '10px'
}
// ...
<
div style = {
this.stylesheet.feed_page
} >
<
List style = {
this.stylesheet.feed_list
}
height = {
1400
}
rowCount = {
this.testPosts.length
}
rowHeight = {
50
}
width = {
800
}
rowRenderer = {
this.b_listItemRender
}
/> <
/div>
listItemRender({
index, // Index of row
isScrolling, // The List is currently being scrolled
isVisible, // This row is visible within the List (eg it is not an overscanned row)
key, // Unique key within array of rendered rows
parent, // Reference to the parent List (instance)
style
}) {
style = {
...style,
...this.stylesheet.feed_item
}
return ( <
div key = {
key
}
style = {
style
} > {
this.testPosts[index]
} <
/div>
);
}
导致(我手动关闭了 1 行的背景):
两个问题:
行之间的边距没有得到尊重
borderBottom 在下一行项目的背景后面渲染,如果我手动将下一行项目向下移动 1 像素或将样式设置为 49 像素的高度,它就会显示出来。
我搞砸了什么?我需要在行元素之间有一个空格,并且每个元素都有一个边框
【问题讨论】:
-
你能从呈现的 html 中制作一个有效的 sn-p...吗?
-
height = 内容的高度。 (边框和填充不包括在计算中。),因此元素的高度为 50 + 边框底部 1px ,因此下一个元素必须从顶部 51 开始,第三个元素必须从顶部 102 px (51+51) - codepen.io/nagasai/pen/YaXVox跨度>
-
这令人失望,我不想在任何地方都必须处理一个接一个的逻辑。边距呢?
-
@StephenEckels,我有 codepen 和 post,margin px 也必须包含在间距中
-
@update option2 以简单的方式达到预期的结果。希望它有效:)
标签: css reactjs react-virtualized