利用flexbox实现div居中的css,高版本IE才支持。不过连微软都放弃IE改用edge了,我们为何还要再垂死挣扎在IE上,不能再纵容老顽固们用IE了。作为一个前端开发我们要为淘汰IE贡献一份自己的力量。
<pre>
.block-center{
display: -webkit-box;
display: -ms-flexbox;
display: -moz-box;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-moz-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-moz-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
</pre>
在父组件中加入该css样式,即可实现子组件在父组件内的居中
网友评论