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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -