1
2<!doctype html>
3<html lang="en">
4<head>
5 <meta charset="utf-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <title>Center Flex Item Image</title>
8<style>
9.box {
10 width:80%;
11 min-height:80vh;
12 margin:auto;
13 border:1px solid;
14 display: flex;
15 align-items: center;
16 justify-content: center; /* not really needed with auto margin on img*/
17}
18.box img {
19 display: block;
20 width: 80%;
21 min-width:100px;
22 max-width: 350px; /*actual image width*/
23 height: auto; /* maintain aspect ratio*/
24 margin: auto; /*optional centering of image*/
25}
26</style>
27
28</head>
29<body>
30
31<div class="box">
32 <img src="http://via.placeholder.com/350x250" width="350" height="250" alt="missing image">
33</div>
34
35</body>
36</html>
37