steveosoule
7/12/2013 - 12:03 AM

Centering Percentage Width/Height Elements

Centering Percentage Width/Height Elements

/* http://css-tricks.com/centering-percentage-widthheight-elements */
.center {
  position: absolute;
  left: 50%;
  top: 50%;
  
  /*
  Nope =(
  margin-left: -25%;
  margin-top: -25%;
  */

  /* 
  Yep!
  */
  transform: translate(-50%, -50%);
  
  /*
  Not even necessary really. 
  e.g. Height could be left out!
  */
  width: 40%;
  height: 50%;
}