Answers for "centering the div"

CSS
0

center a div

.parent {
	justify-content : center;
    align-items : center;
}
Posted by: Guest on January-23-2022
2

how to center div

<!--center text-->
<!--padding deals with margins within the element itself-->
<!--margin deals with blank space surrounding and element-->
<!DOCTYPE html>
<html>
<head>
<style>
.center {
  margin: auto;
  width: 80%;
  border: 3px solid #73AD21;
  padding: 10px; 
  margin: 20px;
}
</style>
</head>
<body>

<h2>Center Align Elements</h2>
<p>To horizontally center a block element (like div), use margin: auto;</p>

<div class="center">
  <p><b>Note: </b>Using margin:auto will not work in IE8, unless a !DOCTYPE is declared.</p>
</div>

</body>
</html>
Posted by: Guest on June-21-2020
0

how to center a div

<div id="outer">
  <div id="inner">Foo foo</div>
</div>
Posted by: Guest on March-17-2022
-1

how to center div

centering div
Posted by: Guest on October-28-2021

Browse Popular Code Answers by Language