作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 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/
我是一名优秀的程序员,十分优秀!