CSS居中方案介绍

1. 水平居中 1.1. transform居中 通过transform居中的核心思想是让居中元素先通过margin-left属性向右移动50%,然后再利用transform属性左移元素宽度的一半,从而达到居中的效果: .parent { position:relative; width: 300px; height: 400px; background-color: red; }
相关文章
相关标签/搜索