如何垂直和水平居中对齐DIV(How to align DIV vertically & horizontally center)

有人可以帮助我将div id“loader”浮在div class“Window”的中心。 谢谢。

<div id="someid" class="Window"> <div id="loader"></div> </div>

更新*我需要将它集中在块的绝对中间。 可以说类“窗口”是400px高。 如何让“装载机浮在中心(高度/宽度)”?

Can someone help me to get div id "loader" to float in the center of div class "Window". Thanks.

<div id="someid" class="Window"> <div id="loader"></div> </div>

UPDATE* I need to center it in the absolute middle of a block. Lets say class "Window" was 400px high. How do I get "loader to float in the center (height/width) of that?

最满意答案

将以下CSS应用于“加载器”:

位置:相对 顶部:50% 保证金: - {E} px auto auto auto

其中{E}是“装载机”的一半高度

希望这可以帮助。

Apply the following CSS to "loader":

position: relative top: 50% margin: -{E}px auto auto auto

where {E} is half the height of "loader"

Hope this helps.

更多推荐

loader,id,class,Window,center,电脑培训,计算机培训,IT培训"/> <meta name="