字面上以所有四个边为中心。我看到很多教程都在使用
element.style.margin = "0 auto";这仅使其在X轴上居中,而不在Y轴上居中。
我如何让它也通过Y轴居中?
发布于 2013-02-01 03:51:39
我使用过:
#myItem {
position: fixed;
top: 50%;
left: 50%;
width: 100px;
height: 100px;
margin-top: -50px;
margin-left: -50px;
}……在此之前,希望它能有所帮助
发布于 2013-02-01 03:52:39
在想要垂直居中的元素上设置display: table-cell和vertical-align: middle,在想要在其内部居中的父容器元素上设置display: table。
https://stackoverflow.com/questions/14633963
复制相似问题