Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align DIV vertically & horizontally center

Tags:

css

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?

like image 557
Joe Avatar asked Feb 22 '12 17:02

Joe


1 Answers

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.

like image 111
SenorAmor Avatar answered Sep 18 '22 23:09

SenorAmor