📜  如何使 html 元素位于屏幕中心 - Html 代码示例

📅  最后修改于: 2022-03-11 14:52:55.930000             🧑  作者: Mango

代码示例2
// Replace X and Y with a number and u with a unit. do calculations
 // and remove parens
.centered_div {
   width: Xu;
   height: Yu;
   position: absolute;
   top: 50%;
   left: 50%;
   margin-left: -(X/2)u;
   margin-top: -(Y/2)u;
}