0
Q:

align center css

.class {
	text-align: center;
}
19
//HTML
<div class="parent">
	<span>Hello World</span>
</div>

//CSS
.parent {
  display: flex;
  justify-content: center;
  align-items: center;
}
11
/* this will center all children within the parent element. */
.parent {
  display: flex;
  justify-content: center; /* horizontal */
  align-items: center; /* vertical */
}
3
.parent {
  position: relative;
}
.child {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
1
.parent {
  position: relative;
}
.child {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
3
<switch>
    h1 {
    text-align: center;
}

p.date {
    text-align: right;
}

 
p.main {
    text-align: justify;
} 
</Switch>
4
.container{	
	margin: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    -ms-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
  	width: /* Define the width here; */
    height: /* Define the height here; */
}

/*You have to define the width and height! */
2

.center
{

  margin: auto;

   
width: 50%;

   
border: 3px solid green;
  padding: 10px;

} 
4
.center {
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}
-1
.center {
  margin: auto;
  width: 50%;
  border: 3px solid green;
  padding: 10px;
}
1
margin: auto;
0

New to Communities?

Join the community