, - . . x (horizontal), y (vertical) axis , , . flexbox.
<div id="imageBox">
<img src="my-image.png" alt="some text" />
</div>
#imageBox
{
display:flex;
flex-direction:column;
justify-content:center;
width: 400px;
height: 400px;
}
#imageBox img
{
margin: 0 auto;
}
DEMO .
, flexbox, img .
#imageBox
{
display: flex;
flex-direction: row;
justify-content: center;
}
, flex-direction column row, . , . column .
, flexbox.
- flexbox IE, IE < 11 IE-10.
- (
#imgBox ) , . : 0 auto , .. width ( ), margin: 0 auto CSS.
:
flexbox, . inline -, width height, , text-align, ...
#imageBox
{
text-align: center;
}
img . Vertical-align . . .
display: table display: table-cell text-align: center vertical-align: middle table-cell , , .