center divs code example
Example 1: center a div in css
.container {
display: flex;
justify-content: center;
align-items: center;
}
Example 2: how to horizontal center a div in css
#inner {
width: 50%;
margin: 0 auto;
}
Example 3: css main container align center
margin: 0 auto;
Example 4: align a div in center of another div
#container {
width: 640px;
height: auto;
margin: 0 auto;
padding: 10px;
position: relative;
}
Example 5: how to center a div
margin:auto
Example 6: center a div
<div id="outer">
<div id="inner">Foo foo</div>
</div>
//css:, demo with border
<style>
#inner {
display: table;
margin: 0 auto;
border: 1px solid black;
}
#outer {
border: 1px solid red;
width:100%
}
</style>