how to center element css code example

Example 1: center a div in css

.container {
  display: flex;
  justify-content: center;
  align-items: center;
}

Example 2: css align items vertical center

.parent {
  display: flex;
  justify-content: center;
  align-items: center;
}

Example 3: mettre une image au milieu css

IMG.displayed {
    display: block;
    margin-left: auto;
    margin-right: auto }
 ...
<IMG class="displayed" src="..." alt="...">

Example 4: css align center vertical and horizontal

.parent-class {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

Example 5: how to center text in css

.class {
	text-align: center;
}

Example 6: center css elements

body{
  display: grid;
  place-items: center;
}

Tags:

Misc Example