20
Q:

css center

.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
21
//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
IMG.displayed {
    display: block;
    margin-left: auto;
    margin-right: auto }
 ...
<IMG class="displayed" src="..." alt="...">
1
.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
// add to the parent element
.parent {
	display: grid;
    place-items: center;
}
3

  .center {
  display: flex;
  justify-content: center;
  
  align-items: center;
  height: 200px;
  border: 3px solid 
  green; 
} 
3
.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
// example 1 
div { display: grid; place-items: center; }

// example 3
div{ display:flex; align-items:center; }

// example 3
div { width: 100%; margin: 0 auto; }
1

New to Communities?

Join the community