CSSのflexプロパティを使うと、均等配置や順番の指定などができ便利ですが、
floatのように、右寄せ、左寄せにしたい場合もあります。
左寄せしたい場合は、margin-right: auto;
右寄せにしたい場合は、margin-left: auto;
中央寄せにしたい場合は、margin-left: auto;margin-right: auto;
を指定します。
HTML
<div class="flex"> <div class="leftBox">LeftBox</div> <div class="centerBox">centerBox</div> <div class="rigthBox">RigthBox</div> </div>
CSS
.flex {
width: 100%;
margin: 0 auto;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: -o-flex;
display: flex;
justify-content: center;
align-items: center;
}
.leftBox {
width: 300px;
height: 50px;
margin-right: auto;
background: red;
}
.centerBox {
width: 300px;
height: 50px;
margin-left: auto;
margin-right: auto;
background: green;
}
.rigthBox {
width: 300px;
height: 50px;
margin-left: auto;
background: blue;
}