center content code example

Example 1: css center image

.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

Example 2: css align center

//HTML
<div class="parent">
	<span>Hello World</span>
</div>

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

Example 3: how to make a division center css

position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);

Example 4: css center

// example 1 
div { display: grid; place-items: center; }

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

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

Example 5: css text align center

body {
  text-align: center;
}

Example 6: css align center

.center {
  margin: auto;
  width: 50%;
  border: 3px solid green;
  padding: 10px;
}

Tags:

Html Example