<h2>margin-left: auto</h2>
<div class="wrap">
<div class="box margin-left">margin-left: auto</div>
</div>
<h2>margin-right: auto</h2>
<div class="wrap">
<div class="box margin-right">margin-right: auto</div>
</div>
<h2>margin: auto</h2>
<div class="wrap">
<div class="box margin-auto">margin: auto</div>
</div>
.wrap{
border:1px solid;
}
.box{
width:200px;
padding:40px 0;
text-align:center;
background-color:lightpink;
color:#333;
}
.margin-left{
margin-left: auto;
}
.margin-right{
margin-right: auto;
}
.margin-auto{
margin: auto;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.