<div class="centered">Success! I'm centered!</div>
@mixin centered {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

html {
  margin-top: 25px;
  margin-bottom: 25px;
}
.centered {
  @include centered;
  background: #000;
  padding: 20px 40px;
  color: #FFF;
}
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.