css center image horizontal and vertical flexbox
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Center Flex Item Image</title>
<style>
.box {
width:80%;
min-height:80vh;
margin:auto;
border:1px solid;
display: flex;
align-items: center;
justify-content: center; /* not really needed with auto margin on img*/
}
.box img {
display: block;
width: 80%;
min-width:100px;
max-width: 350px; /*actual image width*/
height: auto; /* maintain aspect ratio*/
margin: auto; /*optional centering of image*/
}
</style>
</head>
<body>
<div class="box">
<img src="http://via.placeholder.com/350x250" width="350" height="250" alt="missing image">
</div>
</body>
</html>
Also in CSS:
- css grid align
- !important css
- how to clear floats
- make div the size of the text inside
- how to use visited hover active and visited in css
- all cursor types
- scss hover
- round image css
- pseudo elements css
- not last child css
- how to highlight text in css
- blur effect css
- reseting css
- how to make a popup in html and css
- css clear both
- django cannot update static css
- remove html scroll bar
- How to find the key of the largest value hash?
- css calss
- justify text csss
- css grid gap
- css border
- semantic ui react sidebar background
- display table css