Skip to content

Comment on CSS Challenge

Comments

Done! Works in every single browser.

  div {
  background: red;
  width: 250px;
  height: 250px;
  top: 50%;
  left: 50%;
  position: absolute;
  margin: -125px 0 0 -125px; /* Width of Element / 2 = Negative Left Margin
				Height of Element / 2 = Negative Top Margin */
 }
Live demo http://www.faramarzhashemi.com/valign.html
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.