Yay
0
Q:

css align center vertical and horizontal

.parent {
  display: flex;
  justify-content: center;
  align-items: center;
}
8
.parent {
  position: relative;
}
.child {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
1
.parent-class {
  display: flex;
  align-items: center;
  justify-content: space-around;
}
3

  <style>
.container { 
  height: 200px;
  position: 
  relative;
  border: 3px solid green; 
}

.center {
  margin: 0;
  
  position: absolute;
  top: 50%;
  left: 50%;
  -ms-transform: 
  translate(-50%, -50%);
  transform: translate(-50%, -50%);
}
</style>

<div 
  class="container">
  <div class="center">
    
  <p>I am vertically and horizontally centered.</p>
  </div>
</div> 
4
div.center{display:block;margin:auto;width:50%;}
p.center{text-align:center;}
3

New to Communities?

Join the community