html - CSS Resize images to fit in a container -


i want fit images in container different images size :

example :

1. full size in container bigger size.

2. middle in container horizontal size.

3. middle in container vertical size.

check out example link

as gautam said, need use

max-height:100%; max-width: 100%; 

so can define class containers

.container {     display:flex;     align-items:center;     justify-content:center;     border:1px solid black;     background-color: #ffffff;     width: 50px;     height: 50px; } 

and class images

.maxsize {     max-height:100%;     max-width: 100%; } 

the display:flex; property makes container easier config, can center contents faster. can remove border property, it's easier viewing of container edges. hope helps.

updated jsfiddle


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -