技术栈:Meteor + React + Material UI
这是我“主要”的渲染组件的完整代码:
// Sorry for not giving material-UI CSS,
// cause it cannot be served as a stand-alone CSS
render() {
return (
<div className = "container">
<AppBar title = "test" />
<Tabs /> // Tab contents goes here
<RefreshIndicator
left={70} // Required properties
top={0} // Required properties
status="loading"
style={{
display: 'inline-block',
position: 'relative',
margin: '0 auto' }} />
</div>
);
},
我想让刷新指示器水平居中于我的标签页下方,就像这张图片中的旋转圆圈一样: 在Material UI的文档这里中,该指示器带有以下样式:
display: 'inline-block',
position: 'relative',
使用这些样式我无法水平居中对齐,而没有这些样式,我甚至无法将其定位到我想要的位置。
我尝试过:
- margin: 0 auto --> 失败
- text-align: center --> 失败
- display: flex --> 失败
- 1和2的组合 --> 失败
- left={$(window).width/2-20} --> 这个方法可以,但我想仅使用CSS
position: 'relative'
并检查一下吗? - Aditya Singhjustify-content:center
将其居中。 - lux<div sytle={{ display: 'flex', justifyContent: 'center' }}><RefreshIndicator left={70} top={0} status="loading" style={{ display: 'inline-block', position: 'relative', margin: '0 auto' }}/> </div>
但是失败了。 - Junho Kim