简体   繁体   English

如何使用CSS中心表单?

[英]how to center a form using css?

Literally centering on ALL four sides. 从字面上看四面都有。 I see lots of tutorials just using 我看到很多教程正在使用

element.style.margin = "0 auto";

This only centers it on the X-Axis, but not the Y-axis. 这仅以X轴为中心,而不是Y轴。

How do I get it to center via Y-Axis as well? 如何通过Y轴将其置于中心位置?

I've used: 我用过:

#myItem {
   position: fixed;
   top: 50%;
   left: 50%;
   width: 100px;
   height: 100px;
   margin-top: -50px;
   margin-left: -50px;
}

.... before, hope it helps ....之前,希望它有所帮助

在要垂直居中的元素上设置display: table-cellvertical-align: middle ,并在其父级容器元素上设置display: table ,使其居中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM