HTML CSS examples for CSS Layout:Flex Container
keep aspect ratio of image inside flexbox with flex:1
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .slider {<!-- ww w . j a va 2 s . c om--> display: flex; flex: 1; align-items: center; } .slider img { width: 100%; } </style> </head> <body> <div class="slider"> <img src="https://www.java2s.com/style/demo/Safari.png" alt="Bacn"> </div> </body> </html>