如何将图像置于div中间?

Dan*_*iel 4 html css position vertical-alignment css3

我需要将图像置于div的中间.

<div class="main">
    <img...>
</div>
Run Code Online (Sandbox Code Playgroud)

在下面的示例中,图像居中,但不在中间.

https://jsfiddle.net/web_garaux/tng7db0k/

cod*_*yan 15

简单易行的方法,

.test {
  background-color: orange;
  width: 700px;
  height: 700px;
  display:flex;
  align-items:center;
  justify-content:center;
}
Run Code Online (Sandbox Code Playgroud)
<div class="test">
<img src="http://via.placeholder.com/350x150">
</div>
Run Code Online (Sandbox Code Playgroud)