我的 css,所以我可以获得浏览器的宽度和高度:
body, html {
margin:0;
padding:0;
line-height: 1.5em;
height: 100% !important;
width: 100% !important;
}
这就是我希望其子项居中的内容:
<div style={{marginLeft: 'auto', marginRight: 'auto', width: 'inherit', height: 'inherit'}}>
<ul style={{listStyle: 'none'}}>
{this._renderTodos()}
</ul>
<Button primary onClick={()=>this._loadMore()}> Load More </Button>
</div>
我想让父div继承浏览器的宽高,我用了margin left和right等于auto,但是没有居中?
最佳答案
将您的 CSS 更改为:
body{
margin: 0 auto;
}
关于html - 如何在CSS中自动居中 child ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45828672/